Re: [PATCH 1/2] Update git to use "git diff-index" instead of "git status"



On Mon, Mar 1, 2010 at 12:38 AM, Kai Willadsen <kai willadsen gmail com> wrote:
> Patches! that look good! and have commit messages! You're my hero for the day.

I aim to please!:)

> On 1 March 2010 06:42, Peter Tyser <ptyser gmail com> wrote:
> <snip>
>> @@ -39,12 +39,12 @@ class Vc(_vc.CachedVc):
>>     PATCH_STRIP_NUM = 1
>>     PATCH_INDEX_RE = "^diff --git a/(.*) b/.*$"
>>     state_map = {
>> -        "unknown":    _vc.STATE_NONE,
>> -        "new file":   _vc.STATE_NEW,
>> -        "deleted":    _vc.STATE_REMOVED,
>> -        "modified":   _vc.STATE_MODIFIED,
>> -        "typechange": _vc.STATE_MODIFIED,
>> -        "unmerged":   _vc.STATE_CONFLICT,
>> +        "X": _vc.STATE_NONE,     # Unknown
>> +        "A": _vc.STATE_NEW,      # New
>> +        "D": _vc.STATE_REMOVED,  # Deleted
>> +        "M": _vc.STATE_MODIFIED, # Modified
>> +        "T": _vc.STATE_MODIFIED, # Type-changed
>> +        "U": _vc.STATE_CONFLICT, # Unmerged
>>     }
>
> So this won't handle renames or copies. The old code treated rename as
> new/deleted, and a copy as a straight new. I guess adding --no-renames
> to the command line would give us the same result for the rename case?
> I couldn't find an equivalent for no copies, but I'm sure it's around
> somewhere.

Ahh, good point.  The patch handles renames and copies, but just as
the addition/deletion of files.  It'd be much nicer to detect the
rename/copy and create a relevant diff as you suggest.  I'm pretty
sure "git diff-index -M" should do the trick.  This would have the
same functionality as the previous code where renames, but not copies
are detected.

It could be argued that detecting copies would be nice too (eg add -C
to "git diff-index").  Git can detect copied files with changes, so
the diff might actually be usefully when copying and slightly
modifying a file from the original.  Let me know if you have any
issues with this operation as it is slightly different from the
original code.

I'll rework the patch and resubmit.  Thanks for the comments,
Peter


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]