summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3f680ff)
raw | patch | inline | side by side (parent: 3f680ff)
author | Elijah Newren <newren@gmail.com> | |
Fri, 12 Aug 2011 05:20:25 +0000 (23:20 -0600) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 14 Aug 2011 21:19:40 +0000 (14:19 -0700) |
Calling update_stages() before update_file() can sometimes result in git
thinking the file being updated is untracked (whenever update_stages
moves it to stage 3). Reverse the call order, and add a big comment to
update_stages to hopefully prevent others from making the same mistake.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
thinking the file being updated is untracked (whenever update_stages
moves it to stage 3). Reverse the call order, and add a big comment to
update_stages to hopefully prevent others from making the same mistake.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive.c | patch | blob | history | |
t/t6022-merge-rename.sh | patch | blob | history |
diff --git a/merge-recursive.c b/merge-recursive.c
index c7d5a4591bdf16cb2d2b639e37192a1532fb26f1..2bebc9721c3c494c888ef8fac12bed05094d0698 100644 (file)
--- a/merge-recursive.c
+++ b/merge-recursive.c
const struct diff_filespec *a,
const struct diff_filespec *b)
{
+
+ /*
+ * NOTE: It is usually a bad idea to call update_stages on a path
+ * before calling update_file on that same path, since it can
+ * sometimes lead to spurious "refusing to lose untracked file..."
+ * messages from update_file (via make_room_for path via
+ * would_lose_untracked). Instead, reverse the order of the calls
+ * (executing update_file first and then update_stages).
+ */
int clear = 1;
int options = ADD_CACHE_OK_TO_ADD | ADD_CACHE_SKIP_DFCHECK;
if (clear)
{
const struct diff_filespec *orig = pair->one;
const struct diff_filespec *dest = pair->two;
- const char *path;
const unsigned char *a_sha = NULL;
const unsigned char *b_sha = NULL;
int a_mode = 0;
b_mode = dest->mode;
}
+ handle_change_delete(o,
+ o->call_depth ? orig->path : dest->path,
+ orig->sha1, orig->mode,
+ a_sha, a_mode,
+ b_sha, b_mode,
+ "rename", "renamed");
+
if (o->call_depth) {
remove_file_from_cache(dest->path);
- path = orig->path;
} else {
- path = dest->path;
update_stages(dest->path, NULL,
rename_branch == o->branch1 ? dest : NULL,
rename_branch == o->branch1 ? NULL : dest);
}
- handle_change_delete(o,
- path,
- orig->sha1, orig->mode,
- a_sha, a_mode,
- b_sha, b_mode,
- "rename", "renamed");
}
static struct diff_filespec *filespec_from_entry(struct diff_filespec *target,
}
add = filespec_from_entry(&other, dst_entry, stage ^ 1);
- if (stage == 2)
- update_stages(rename->path, NULL, rename, add);
- else
- update_stages(rename->path, NULL, add, rename);
-
if (add) {
char *add_name = unique_path(o, rename->path, other_branch);
update_file(o, 0, add->sha1, add->mode, add_name);
}
}
update_file(o, 0, rename->sha1, rename->mode, dst_name);
+ if (stage == 2)
+ update_stages(rename->path, NULL, rename, add);
+ else
+ update_stages(rename->path, NULL, add, rename);
if (dst_name != rename->path)
free(dst_name);
index 0fd2b0a10e47e3b77a16600aadcdd828cf5ef601..8f75762bfb6023d04f7ad695977e97763a9e2e03 100755 (executable)
--- a/t/t6022-merge-rename.sh
+++ b/t/t6022-merge-rename.sh
git commit -mC
'
-test_expect_failure 'no spurious "refusing to lose untracked" message' '
+test_expect_success 'no spurious "refusing to lose untracked" message' '
git checkout master^0 &&
test_must_fail git merge rename^0 2>errors.txt &&
! grep "refusing to lose untracked file" errors.txt