summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f3caeb9)
raw | patch | inline | side by side (parent: f3caeb9)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Mon, 17 Sep 2007 00:24:57 +0000 (01:24 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 17 Sep 2007 01:20:10 +0000 (18:20 -0700) |
"git diff" does not record index lines for pure mode changes (i.e. no
lines changed). Therefore, apply --index-info would call out a bogus
error.
Instead, fall back to reading the info from the current index.
Incidentally, this fixes an error where git-rebase would not rebase a
commit including a pure mode change, and changes requiring a threeway
merge.
Noticed and later tested by Chris Shoemaker.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
lines changed). Therefore, apply --index-info would call out a bogus
error.
Instead, fall back to reading the info from the current index.
Incidentally, this fixes an error where git-rebase would not rebase a
commit including a pure mode change, and changes requiring a threeway
merge.
Noticed and later tested by Chris Shoemaker.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-apply.c | patch | blob | history | |
t/t3400-rebase.sh | patch | blob | history |
diff --git a/builtin-apply.c b/builtin-apply.c
index 976ec770417cba4113c4c55f5ca7a5f7b8520f1e..f4ecf03ed465c942a395f4de5ca3ce17bbdd3011 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
return err;
}
+/* This function tries to read the sha1 from the current index */
+static int get_current_sha1(const char *path, unsigned char *sha1)
+{
+ int pos;
+
+ if (read_cache() < 0)
+ return -1;
+ pos = cache_name_pos(path, strlen(path));
+ if (pos < 0)
+ return -1;
+ hashcpy(sha1, active_cache[pos]->sha1);
+ return 0;
+}
+
static void show_index_list(struct patch *list)
{
struct patch *patch;
if (0 < patch->is_new)
sha1_ptr = null_sha1;
else if (get_sha1(patch->old_sha1_prefix, sha1))
- die("sha1 information is lacking or useless (%s).",
- name);
+ /* git diff has no index line for mode/type changes */
+ if (!patch->lines_added && !patch->lines_deleted) {
+ if (get_current_sha1(patch->new_name, sha1) ||
+ get_current_sha1(patch->old_name, sha1))
+ die("mode change for %s, which is not "
+ "in current HEAD", name);
+ sha1_ptr = sha1;
+ } else
+ die("sha1 information is lacking or useless "
+ "(%s).", name);
else
sha1_ptr = sha1;
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 62205b25312812f3197b38a655d92da4fa7c0a91..95e33b52100bb360ab3fcfa1b419b66321340b8a 100755 (executable)
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
test 3 = $(git rev-list master.. | wc -l)
'
+test_expect_success 'rebase a single mode change' '
+ git checkout master &&
+ echo 1 > X &&
+ git add X &&
+ test_tick &&
+ git commit -m prepare &&
+ git checkout -b modechange HEAD^ &&
+ echo 1 > X &&
+ git add X &&
+ chmod a+x A &&
+ test_tick &&
+ git commit -m modechange A X &&
+ GIT_TRACE=1 git rebase master
+'
+
test_done