* BUG: mergetool fails on gitignore:d files @ 2009-05-30 15:30 Erik Sandberg 2009-05-30 16:38 ` Markus Heidelberg 2009-05-30 21:54 ` Jeff King 0 siblings, 2 replies; 5+ messages in thread From: Erik Sandberg @ 2009-05-30 15:30 UTC (permalink / raw To: git [-- Attachment #1: Type: text/plain, Size: 541 bytes --] If a version-controlled file is ignored by git, and a conflict arises on the file, and I use mergetool to resolve the conflict, then mergetool fails with a message like: The following paths are ignored by one of your .gitignore files: a Use -f if you really want to add them. The problem disappears if I edit the git-mergetool script to always pass -f to "git add", but I'm not sure if that's the right fix; I have a vague feeling that "git-update-index --add" could be more correct. I have attached a script that reproduces the problem. [-- Attachment #2: bug.sh --] [-- Type: application/x-sh, Size: 391 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: BUG: mergetool fails on gitignore:d files 2009-05-30 15:30 BUG: mergetool fails on gitignore:d files Erik Sandberg @ 2009-05-30 16:38 ` Markus Heidelberg 2009-05-30 21:54 ` Jeff King 1 sibling, 0 replies; 5+ messages in thread From: Markus Heidelberg @ 2009-05-30 16:38 UTC (permalink / raw To: Erik Sandberg; +Cc: git Erik Sandberg, 30.05.2009: > If a version-controlled file is ignored by git, and a conflict arises > on the file, and I use mergetool to resolve the conflict, then > mergetool fails with a message like: > > The following paths are ignored by one of your .gitignore files: > a > Use -f if you really want to add them. > > The problem disappears if I edit the git-mergetool script to always > pass -f to "git add", but I'm not sure if that's the right fix; I have > a vague feeling that "git-update-index --add" could be more correct. > > I have attached a script that reproduces the problem. The script would have been more readable if you haven't given both the file and the branch name as well as the file content and the commit message the same string "a". Apart from that I wonder if your real repo also ignores the file 'a' although it is tracked in every branch. If so, why do you ignore it? Markus ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: BUG: mergetool fails on gitignore:d files 2009-05-30 15:30 BUG: mergetool fails on gitignore:d files Erik Sandberg 2009-05-30 16:38 ` Markus Heidelberg @ 2009-05-30 21:54 ` Jeff King 2009-06-01 2:03 ` Jeff King 2009-06-01 2:04 ` Junio C Hamano 1 sibling, 2 replies; 5+ messages in thread From: Jeff King @ 2009-05-30 21:54 UTC (permalink / raw To: Erik Sandberg; +Cc: git On Sat, May 30, 2009 at 05:30:52PM +0200, Erik Sandberg wrote: > If a version-controlled file is ignored by git, and a conflict arises > on the file, and I use mergetool to resolve the conflict, then > mergetool fails with a message like: > > The following paths are ignored by one of your .gitignore files: > a > Use -f if you really want to add them. > > The problem disappears if I edit the git-mergetool script to always > pass -f to "git add", but I'm not sure if that's the right fix; I have > a vague feeling that "git-update-index --add" could be more correct. Actually, I think the problem is not in mergetool at all, but with the dir.c code underlying "git add". "git add" really should not be complaining, because you are not adding a new path at all, but are rather adding content to a tracked path. So this should work (and does): $ echo file >.gitignore $ echo content >file $ git add -f file ;# need -f because we are adding new path $ echo more content >>file $ git add file ;# don't need -f; it is not actually an "other" file This is handled under the hood by the COLLECT_IGNORED option to read_directory. When that code finds an ignored file, it checks the index to make sure it is not actually a tracked file. However, the test it uses does not take into account unmerged entries, and considers them to still be ignored. "git ls-files" uses a more elaborate test and gets the right answer. So I think we want to use the same test: --- diff --git a/dir.c b/dir.c index 0e6b752..bbfcb56 100644 --- a/dir.c +++ b/dir.c @@ -396,7 +396,7 @@ static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathna static struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len) { - if (cache_name_pos(pathname, len) >= 0) + if (!cache_name_is_other(pathname, len)) return NULL; ALLOC_GROW(dir->ignored, dir->ignored_nr+1, dir->ignored_alloc); ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: BUG: mergetool fails on gitignore:d files 2009-05-30 21:54 ` Jeff King @ 2009-06-01 2:03 ` Jeff King 2009-06-01 2:04 ` Junio C Hamano 1 sibling, 0 replies; 5+ messages in thread From: Jeff King @ 2009-06-01 2:03 UTC (permalink / raw To: Junio C Hamano; +Cc: git On Sat, May 30, 2009 at 05:54:18PM -0400, Jeff King wrote: > diff --git a/dir.c b/dir.c > index 0e6b752..bbfcb56 100644 > --- a/dir.c > +++ b/dir.c > @@ -396,7 +396,7 @@ static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathna > > static struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len) > { > - if (cache_name_pos(pathname, len) >= 0) > + if (!cache_name_is_other(pathname, len)) > return NULL; > > ALLOC_GROW(dir->ignored, dir->ignored_nr+1, dir->ignored_alloc); I was all set to write a test for this and re-submit, but you seem to have beat me to it. Thanks. :) -Peff ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: BUG: mergetool fails on gitignore:d files 2009-05-30 21:54 ` Jeff King 2009-06-01 2:03 ` Jeff King @ 2009-06-01 2:04 ` Junio C Hamano 1 sibling, 0 replies; 5+ messages in thread From: Junio C Hamano @ 2009-06-01 2:04 UTC (permalink / raw To: Jeff King; +Cc: Erik Sandberg, git Jeff King <peff@peff.net> writes: > Actually, I think the problem is not in mergetool at all, but with the > dir.c code underlying "git add". "git add" really should not be > complaining, because you are not adding a new path at all, but are > rather adding content to a tracked path. Correct, and thanks. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-06-01 2:04 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-05-30 15:30 BUG: mergetool fails on gitignore:d files Erik Sandberg 2009-05-30 16:38 ` Markus Heidelberg 2009-05-30 21:54 ` Jeff King 2009-06-01 2:03 ` Jeff King 2009-06-01 2:04 ` Junio C Hamano
Code repositories for project(s) associated with this public inbox https://80x24.org/mirrors/git.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).