Skip to contentSkip to conversation

git checkout under 1.7.6 does not properly list untracked files and aborts

PATCH In review Joshua Jensen 4 participants 23 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

This may be an msysGit 1.7.6 issue, as that is what I am using. It also occurs in msysGit 1.7.5, but I am almost certain it did not happen in msysGit 1.7.2.

Given an untracked file in the working directory that has been added to an alternate branch, when switching to that alternate branch, 'git checkout' exits with an error code but does not print anything to the console. It should print an untracked file error.

I have been trying to track this down in code. The point where the error messages are printed, display_error_msgs, is never hit.

I don't have a debugger to trace this on Windows, so I've just been adding lots of debug output. So far, I have not found the catalyst.

I am out on vacation now for the next week and a half. However, I thought I would send this along to see if someone else can confirm the the problem. I'll continue investigation when I'm back.

Thanks.

Josh

#1 lore raw

----- Original Message -----
From: Joshua Jensen
Date: 9/9/2011 2:04 PM

Quoted 5 lines

This may be an msysGit 1.7.6 issue, as that is what I am using. It also occurs in msysGit 1.7.5, but I am almost certain it did not happen in msysGit 1.7.2.

Given an untracked file in the working directory that has been added to an alternate branch, when switching to that alternate branch, 'git checkout' exits with an error code but does not print anything to the console. It should print an untracked file error.

I have been trying to track this down in code. The point where the error messages are printed, display_error_msgs, is never hit.

Okay, so I've tracked this down, but I am unsure what the correct fix is.

In unpack-trees.c's unpack_trees() function, there are some lines that read:

    if (ce->ce_flags & CE_ADDED &&
        verify_absent(ce, ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, o))
            return -1;

If the 'return -1' is changed to 'goto return_failed', then a proper error message appears:

error: The following untracked working tree files would be
overwritten by checkout:
one/file/listed/here.txt
Please move or remove them before you can switch branches. Aborting

The thing is, there are multiple files that would be overwritten by checkout, and I believe an older version of Git showed me the entire list before aborting.

What would be the proper fix here? What am I doing wrong?

Thanks.

Josh

#2 lore raw

----- Original Message -----
From: Joshua Jensen
Date: 9/19/2011 1:44 PM

Quoted 18 lines

----- Original Message -----
From: Joshua Jensen
Date: 9/9/2011 2:04 PM

Quoted 5 lines

This may be an msysGit 1.7.6 issue, as that is what I am using. It also occurs in msysGit 1.7.5, but I am almost certain it did not happen in msysGit 1.7.2.

Given an untracked file in the working directory that has been added to an alternate branch, when switching to that alternate branch, 'git checkout' exits with an error code but does not print anything to the console. It should print an untracked file error.

I have been trying to track this down in code. The point where the error messages are printed, display_error_msgs, is never hit.

Okay, so I've tracked this down, but I am unsure what the correct fix is.

In unpack-trees.c's unpack_trees() function, there are some lines that read:

    if (ce->ce_flags & CE_ADDED &&
        verify_absent(ce, ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, o))
            return -1;

If the 'return -1' is changed to 'goto return_failed', then a proper error message appears:

Quoted 7 lines

error: The following untracked working tree files would be
overwritten by checkout:
one/file/listed/here.txt
Please move or remove them before you can switch branches. Aborting

The thing is, there are multiple files that would be overwritten by checkout, and I believe an older version of Git showed me the entire list before aborting.

While probably not correct, the following patch collects all files that would be overwritten and logs them to the output:

---
 unpack-trees.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
unpack-trees.c +0 -0
index cc616c3..e1f7263 100644
@@ -993,7 +993,7 @@ static int verify_absent(struct cache_entry *, enum unpack_trees_error_types, st
  */
 int unpack_trees(unsigned len, struct tree_desc *t, struct 

unpack_trees_options *o)
{
- int i, ret;

+    int i, ret = 0;
     static struct cache_entry *dfc;
     struct exclude_list el;

@@ -1100,9 +1100,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
* Do the real check now because we have had
* correct CE_NEW_SKIP_WORKTREE
*/
- if (ce->ce_flags & CE_ADDED &&
- verify_absent(ce, ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, o))
- return -1;
+ if (ce->ce_flags & CE_ADDED) {
+ int result = verify_absent(ce, ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, o);
+ ret = min(ret, result);
+ }

             if (apply_sparse_checkout(ce, o)) {
                 ret = -1;
@@ -1112,6 +1113,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
                 empty_worktree = 0;

         }
+        if (ret == -1)
+            goto return_failed;
         if (o->result.cache_nr && empty_worktree) {
             /* dubious---why should this fail??? */
             ret = unpack_failed(o, "Sparse checkout leaves no entry on 

working directory");

Signature · 1 line
1.7.6.msysgit.1
#3 lore raw
In reply to Joshua Jensen

Joshua Jensen venit, vidit, dixit 19.09.2011 21:44:

Quoted 31 lines

----- Original Message -----
From: Joshua Jensen
Date: 9/9/2011 2:04 PM

Quoted 11 lines

This may be an msysGit 1.7.6 issue, as that is what I am using. It also occurs in msysGit 1.7.5, but I am almost certain it did not happen in msysGit 1.7.2.

Given an untracked file in the working directory that has been added to an alternate branch, when switching to that alternate branch, 'git checkout' exits with an error code but does not print anything to the console. It should print an untracked file error.

I have been trying to track this down in code. The point where the error messages are printed, display_error_msgs, is never hit.

Okay, so I've tracked this down, but I am unsure what the correct fix is.

In unpack-trees.c's unpack_trees() function, there are some lines that read:

     if (ce->ce_flags & CE_ADDED &&
         verify_absent(ce, ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, o))
             return -1;

If the 'return -1' is changed to 'goto return_failed', then a proper error message appears:

error: The following untracked working tree files would be
overwritten by checkout:
one/file/listed/here.txt
Please move or remove them before you can switch branches. Aborting

Quoted 5 lines

The thing is, there are multiple files that would be overwritten by checkout, and I believe an older version of Git showed me the entire list before aborting.

What would be the proper fix here? What am I doing wrong?

Can you provide a simple test case, such as this one:

---%<---
#!/bin/sh

rm -Rf utest || exit 1
mkdir utest || exit 1
cd utest || exit 1
git init
echo tracked >a
git add a
git commit -m a a
git branch side
echo tracked >b
git add b
git commit -m b
cat b
git checkout side
cat b
echo untracked >b
cat b
git checkout master
cat b
---%<---

With 1.7.6 and current next this gives (Linux):

Initialized empty Git repository in /tmp/t/utest/.git/ [master (root-commit) b462c80] a

 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a
[master 22d8f2f] b
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 b

tracked
Switched to branch 'side'
cat: b: No such file or directory
untracked
error: The following untracked working tree files would be overwritten by checkout:
b
Please move or remove them before you can switch branches. Aborting
untracked

Does this test reproduce your problem on msysgit?

Michael

#4 lore raw

----- Original Message -----
From: Michael J Gruber
Date: 9/20/2011 9:10 AM

Quoted 25 lines

Can you provide a simple test case, such as this one:

---%<---
#!/bin/sh

rm -Rf utest || exit 1
mkdir utest || exit 1
cd utest || exit 1
git init
echo tracked>a
git add a
git commit -m a a
git branch side
echo tracked>b
git add b
git commit -m b
cat b
git checkout side
cat b
echo untracked>b
cat b
git checkout master
cat b
---%<---

Quoted 1 line

Does this test reproduce your problem on msysgit?

As listed, your script produces the same results on msysGit.

It appears the issue is related to sparse checkouts:

---%<---
#!/bin/sh

rm -Rf utest || exit 1
mkdir utest || exit 1
cd utest || exit 1
git init
git config core.sparseCheckout true
echo *>.git/info/sparse-checkout
echo tracked>a
git add a
git commit -m a a
git branch side
echo tracked>b
git add b
git commit -m b
cat b
git checkout side
cat b
echo untracked>b
cat b
git checkout master
cat b
---%<---

-Josh

#5 lore raw

Joshua Jensen venit, vidit, dixit 20.09.2011 20:26:

Quoted 58 lines

----- Original Message -----
From: Michael J Gruber
Date: 9/20/2011 9:10 AM

Quoted 25 lines

Can you provide a simple test case, such as this one:

---%<---
#!/bin/sh

rm -Rf utest || exit 1
mkdir utest || exit 1
cd utest || exit 1
git init
echo tracked>a
git add a
git commit -m a a
git branch side
echo tracked>b
git add b
git commit -m b
cat b
git checkout side
cat b
echo untracked>b
cat b
git checkout master
cat b
---%<---

Quoted 1 line

Does this test reproduce your problem on msysgit?

As listed, your script produces the same results on msysGit.

It appears the issue is related to sparse checkouts:

---%<---
#!/bin/sh

rm -Rf utest || exit 1
mkdir utest || exit 1
cd utest || exit 1
git init
git config core.sparseCheckout true
echo *>.git/info/sparse-checkout
echo tracked>a
git add a
git commit -m a a
git branch side
echo tracked>b
git add b
git commit -m b
cat b
git checkout side
cat b
echo untracked>b
cat b
git checkout master
cat b
---%<---

Quoted 1 line

-Josh

Interesting. So, it is related to sparse, it seems, and there is also a mistake in the documentation (which contradicts itself, btw). With your script, since all files are requested to be checked out ('*'), none should have skip-worktree set, and the result should be the same as with my version. But I get this:

Initialized empty Git repository in /tmp/t/utest/.git/ [master (root-commit) 5929c8b] a

 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a
[master 60ad69e] b
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 b

tracked
Switched to branch 'side'
cat: b: No such file or directory
untracked
untracked

That is probably the same output as for you. The final "git checkout master" errored out without doing anything and without message. I'll send a few cleanups now, and do some bisecting and thinking later; though there are people whose sparse-knowledge is way less sparse than mine ;)

Michael

#6 lore raw

PATCH 1/3 unpack-trees: print "Aborting" to stderr

display_error_msgs() prints all the errors to stderr already (if any), followed by "Aborting" (if any) to stdout. Make the latter go to stderr instead.

---
 unpack-trees.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
unpack-trees.c +1 -1
index 670b464..237aed8 100644
@@ -159,7 +159,7 @@ static void display_error_msgs(struct unpack_trees_options *o)
 		string_list_clear(rejects, 0);
 	}
 	if (something_displayed)
-		printf("Aborting\n");
+		fprintf(stderr, "Aborting\n");
 }
 
 /*
Signature · 1 line
1.7.7.rc0.469.g9eb94
#7 lore raw

Re: [PATCH 1/3] unpack-trees: print "Aborting" to stderr

Forgot to update a test or two that this breaks?

#8 lore raw

Re: [PATCH 1/3] unpack-trees: print "Aborting" to stderr

Quoted 1 line · Junio C Hamano

Forgot to update a test or two that this breaks?

In the meantime I've squashed this in.

 t/t7607-merge-overwrite.sh     |    1 +
 t/t7609-merge-co-error-msgs.sh |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)
t/t7607-merge-overwrite.sh +1 -0
index 72a8731..aa74184 100755
@@ -107,6 +107,7 @@ error: The following untracked working tree files would be overwritten by merge:
 	sub
 	sub2
 Please move or remove them before you can merge.
+Aborting
 EOF
 
 test_expect_success 'will not overwrite untracked file in leading path' '
t/t7609-merge-co-error-msgs.sh +5 -0
index c994836..0e4a682 100755
@@ -32,6 +32,7 @@ error: The following untracked working tree files would be overwritten by merge:
 	three
 	two
 Please move or remove them before you can merge.
+Aborting
 EOF
 
 test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' '
@@ -56,6 +57,7 @@ Please, commit your changes or stash them before you can merge.
 error: The following untracked working tree files would be overwritten by merge:
 	five
 Please move or remove them before you can merge.
+Aborting
 EOF
 
 test_expect_success 'untracked files or local changes ovewritten by merge' '
@@ -71,6 +73,7 @@ error: Your local changes to the following files would be overwritten by checkou
 	rep/one
 	rep/two
 Please, commit your changes or stash them before you can switch branches.
+Aborting
 EOF
 
 test_expect_success 'cannot switch branches because of local changes' '
@@ -92,6 +95,7 @@ error: Your local changes to the following files would be overwritten by checkou
 	rep/one
 	rep/two
 Please, commit your changes or stash them before you can switch branches.
+Aborting
 EOF
 
 test_expect_success 'not uptodate file porcelain checkout error' '
@@ -105,6 +109,7 @@ error: Updating the following directories would lose untracked files in it:
 	rep
 	rep2
 
+Aborting
 EOF
 
 test_expect_success 'not_uptodate_dir porcelain checkout error' '
#9 lore raw

Re: [PATCH 1/3] unpack-trees: print "Aborting" to stderr

Junio C Hamano venit, vidit, dixit 22.09.2011 00:40:

Quoted 5 lines
Quoted 1 line · Junio C Hamano

Forgot to update a test or two that this breaks?

In the meantime I've squashed this in.

Yikes. Sorry and thanks!

Quoted 61 lines
 t/t7607-merge-overwrite.sh     |    1 +
 t/t7609-merge-co-error-msgs.sh |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)
t/t7607-merge-overwrite.sh +1 -0
index 72a8731..aa74184 100755
@@ -107,6 +107,7 @@ error: The following untracked working tree files would be overwritten by merge:
 	sub
 	sub2
 Please move or remove them before you can merge.
+Aborting
 EOF
 
 test_expect_success 'will not overwrite untracked file in leading path' '
t/t7609-merge-co-error-msgs.sh +5 -0
index c994836..0e4a682 100755
@@ -32,6 +32,7 @@ error: The following untracked working tree files would be overwritten by merge:
 	three
 	two
 Please move or remove them before you can merge.
+Aborting
 EOF
 
 test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' '
@@ -56,6 +57,7 @@ Please, commit your changes or stash them before you can merge.
 error: The following untracked working tree files would be overwritten by merge:
 	five
 Please move or remove them before you can merge.
+Aborting
 EOF
 
 test_expect_success 'untracked files or local changes ovewritten by merge' '
@@ -71,6 +73,7 @@ error: Your local changes to the following files would be overwritten by checkou
 	rep/one
 	rep/two
 Please, commit your changes or stash them before you can switch branches.
+Aborting
 EOF
 
 test_expect_success 'cannot switch branches because of local changes' '
@@ -92,6 +95,7 @@ error: Your local changes to the following files would be overwritten by checkou
 	rep/one
 	rep/two
 Please, commit your changes or stash them before you can switch branches.
+Aborting
 EOF
 
 test_expect_success 'not uptodate file porcelain checkout error' '
@@ -105,6 +109,7 @@ error: Updating the following directories would lose untracked files in it:
 	rep
 	rep2
 
+Aborting
 EOF
 
 test_expect_success 'not_uptodate_dir porcelain checkout error' '
#10 lore raw
In reply to Michael J Gruber

Michael J Gruber venit, vidit, dixit 21.09.2011 09:47:

Quoted 19 lines

Interesting. So, it is related to sparse, it seems, and there is also a mistake in the documentation (which contradicts itself, btw). With your script, since all files are requested to be checked out ('*'), none should have skip-worktree set, and the result should be the same as with my version. But I get this:

Initialized empty Git repository in /tmp/t/utest/.git/ [master (root-commit) 5929c8b] a

 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a
[master 60ad69e] b
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 b

tracked
Switched to branch 'side'
cat: b: No such file or directory
untracked
untracked

Quoted 5 lines

That is probably the same output as for you. The final "git checkout master" errored out without doing anything and without message. I'll send a few cleanups now, and do some bisecting and thinking later; though there are people whose sparse-knowledge is way less sparse than mine ;)

So, I bisected it. The first bad commit is

9037026 (unpack-trees: fix sparse checkout's "unable to match directories", 2010-11-27)

although the real culprit may be its predecessor

2431afb (unpack-trees: move all skip-worktree checks back to unpack_trees(), 2010-11-27)

which does not compile:

CC unpack-trees.o
unpack-trees.c: In function 'mark_new_skip_worktree':
unpack-trees.c:852:75: error: 'o' undeclared (first use in this function) unpack-trees.c:852:75: note: each undeclared identifier is reported only once for each function it appears in
make: *** [unpack-trees.o] Error 1

So, this problem was introduced after v1.7.3.2. Given the extent of those two commits, I can't help further (but your proposed fix may be fine).

Duy, sorry for prodding you again. My bisect script was (based on Joshua's, based on mine):

#!/bin/sh
GIT_EXEC_DIR=~/src/git
PATH=$GIT_EXEC_DIR:$PATH
export GIT_EXEC_DIR
d=/tmp/t/utest
rm -Rf $d || exit 1
mkdir $d || exit 1
cd $d || exit 1
git init
git config core.sparseCheckout true
echo *>.git/info/sparse-checkout
echo tracked>a
git add a
git commit -m a a
git branch side
echo tracked>b
git add b
git commit -m b
git checkout side
echo untracked>b
git checkout master 2>&1 | grep "would be"

Hope this helps.

Michael

#11 lore raw
Quoted 10 lines · Michael J Gruber

So, I bisected it. The first bad commit is

9037026 (unpack-trees: fix sparse checkout's "unable to match directories", 2010-11-27)

although the real culprit may be its predecessor

2431afb (unpack-trees: move all skip-worktree checks back to unpack_trees(), 2010-11-27)

Quoted 8 lines

which does not compile:

CC unpack-trees.o
unpack-trees.c: In function 'mark_new_skip_worktree':
unpack-trees.c:852:75: error: 'o' undeclared (first use in this function) unpack-trees.c:852:75: note: each undeclared identifier is reported only once for each function it appears in
make: *** [unpack-trees.o] Error 1

This may help

--8<--

unpack-trees.c +3 -3
index a6518db..a239af7 100644
@@ -245,13 +245,13 @@ static int check_updates(struct unpack_trees_options *o)
 static int verify_uptodate_sparse(struct cache_entry *ce, struct unpack_trees_options *o);
 static int verify_absent_sparse(struct cache_entry *ce, enum unpack_trees_error_types, struct unpack_trees_options *o);
 
-static int will_have_skip_worktree(const struct cache_entry *ce, struct unpack_trees_options *o)
+static int will_have_skip_worktree(const struct cache_entry *ce, struct exclude_list *el)
 {
 	const char *basename;
 
 	basename = strrchr(ce->name, '/');
 	basename = basename ? basename+1 : ce->name;
-	return excluded_from_list(ce->name, ce_namelen(ce), basename, NULL, o->el) <= 0;
+	return excluded_from_list(ce->name, ce_namelen(ce), basename, NULL, el) <= 0;
 }
 
 static int apply_sparse_checkout(struct cache_entry *ce, struct unpack_trees_options *o)
@@ -849,7 +849,7 @@ static void mark_new_skip_worktree(struct exclude_list *el,
 		if (select_flag && !(ce->ce_flags & select_flag))
 			continue;
 
-		if (!ce_stage(ce) && will_have_skip_worktree(ce, o))
+		if (!ce_stage(ce) && will_have_skip_worktree(ce, el))
 			ce->ce_flags |= skip_wt_flag;
 		else
 			ce->ce_flags &= ~skip_wt_flag;

--8<--

Quoted 1 line

Duy, sorry for prodding you again.

No problem (and sorry for breaking the build). I'll also have a look at this problem.

#12 lore raw

Nguyen Thai Ngoc Duy venit, vidit, dixit 21.09.2011 10:58:

Quoted 54 lines · Michael J Gruber
Quoted 10 lines

So, I bisected it. The first bad commit is

9037026 (unpack-trees: fix sparse checkout's "unable to match directories", 2010-11-27)

although the real culprit may be its predecessor

2431afb (unpack-trees: move all skip-worktree checks back to unpack_trees(), 2010-11-27)

Quoted 8 lines

which does not compile:

CC unpack-trees.o
unpack-trees.c: In function 'mark_new_skip_worktree':
unpack-trees.c:852:75: error: 'o' undeclared (first use in this function) unpack-trees.c:852:75: note: each undeclared identifier is reported only once for each function it appears in
make: *** [unpack-trees.o] Error 1

This may help

--8<--

unpack-trees.c +3 -4
index a6518db..a239af7 100644
@@ -245,13 +245,13 @@ static int check_updates(struct unpack_trees_options *o)
 static int verify_uptodate_sparse(struct cache_entry *ce, struct unpack_trees_options *o);
 static int verify_absent_sparse(struct cache_entry *ce, enum unpack_trees_error_types, struct unpack_trees_options *o);
 
-static int will_have_skip_worktree(const struct cache_entry *ce, struct unpack_trees_options *o)
+static int will_have_skip_worktree(const struct cache_entry *ce, struct exclude_list *el)
 {
 	const char *basename;
 
 	basename = strrchr(ce->name, '/');
 	basename = basename ? basename+1 : ce->name;
-	return excluded_from_list(ce->name, ce_namelen(ce), basename, NULL, o->el) <= 0;
+	return excluded_from_list(ce->name, ce_namelen(ce), basename, NULL, el) <= 0;
 }
 
 static int apply_sparse_checkout(struct cache_entry *ce, struct unpack_trees_options *o)
@@ -849,7 +849,7 @@ static void mark_new_skip_worktree(struct exclude_list *el,
 		if (select_flag && !(ce->ce_flags & select_flag))
 			continue;
 
-		if (!ce_stage(ce) && will_have_skip_worktree(ce, o))
+		if (!ce_stage(ce) && will_have_skip_worktree(ce, el))
 			ce->ce_flags |= skip_wt_flag;
 		else
 			ce->ce_flags &= ~skip_wt_flag;
--8<--
Quoted 4 lines
Quoted 1 line

Duy, sorry for prodding you again.

No problem (and sorry for breaking the build). I'll also have a look at this problem.

Thanks. I can confirm that with the above patch, the code compiles and fails my test. So it's the earlier of the two commits which introduces this.

Michael

#13 lore raw
Quoted 2 lines · Michael J Gruber

Thanks. I can confirm that with the above patch, the code compiles and fails my test. So it's the earlier of the two commits which introduces this.

I was afraid some logic had gone horribly wrong. Turns out I did not catch up with unpack_trees() coding style and drop the error messages so "git checkout" in this case becomes "git checkout -q".

This patch should fix it. Need another look before I submit a real patch though.

unpack-trees.c +3 -5
index cc616c3..79e9e88 100644
@@ -1102,12 +1102,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
 			 */
 			if (ce->ce_flags & CE_ADDED &&
 			    verify_absent(ce, ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, o))
-					return -1;
+				goto return_failed;
 
-			if (apply_sparse_checkout(ce, o)) {
-				ret = -1;
-				goto done;
-			}
+			if (apply_sparse_checkout(ce, o))
+				goto return_failed;
 			if (!ce_skip_worktree(ce))
 				empty_worktree = 0;
 
#14 lore raw
Quoted 3 lines · Nguyen Thai Ngoc Duy

I was afraid some logic had gone horribly wrong. Turns out I did not catch up with unpack_trees() coding style and drop the error messages so "git checkout" in this case becomes "git checkout -q".

Gaah.. if I did read Joshua's problem description, it would not need to worry about the logic. He said it returned error code correctly. Silly me.

Signature · 1 line
Duy
#15 lore raw

PATCH 2/3 git-read-tree.txt: language and typography fixes

In reply to Michael J Gruber

Fix a few missing articles and such, and mark-up 'commands' and files appropriately.

---
 Documentation/git-read-tree.txt |   40 +++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 20 deletions(-)
Documentation/git-read-tree.txt +20 -20
index c45d53c..0004f4b 100644
@@ -47,7 +47,7 @@ OPTIONS
 
 -i::
 	Usually a merge requires the index file as well as the
-	files in the working tree are up to date with the
+	files in the working tree to be up to date with the
 	current head commit, in order not to lose local
 	changes.  This flag disables the check with the working
 	tree and is meant to be used when creating a merge of
@@ -71,21 +71,21 @@ OPTIONS
 --aggressive::
 	Usually a three-way merge by 'git read-tree' resolves
 	the merge for really trivial cases and leaves other
-	cases unresolved in the index, so that Porcelains can
+	cases unresolved in the index, so that porcelains can
 	implement different merge policies.  This flag makes the
-	command to resolve a few more cases internally:
+	command resolve a few more cases internally:
 +
 * when one side removes a path and the other side leaves the path
   unmodified.  The resolution is to remove that path.
 * when both sides remove a path.  The resolution is to remove that path.
-* when both sides adds a path identically.  The resolution
+* when both sides add a path identically.  The resolution
   is to add that path.
 
 --prefix=<prefix>/::
 	Keep the current index contents, and read the contents
-	of named tree-ish under directory at `<prefix>`.  The
+	of the named tree-ish under the directory at `<prefix>`. The
 	original index file cannot have anything at the path
-	`<prefix>` itself, and have nothing in `<prefix>/`
+	`<prefix>` itself, nor anything in the `<prefix>/`
 	directory.  Note that the `<prefix>/` value must end
 	with a slash.
 
@@ -379,15 +379,15 @@ have finished your work-in-progress), attempt the merge again.
 Sparse checkout
 ---------------
 
-"Sparse checkout" allows to sparsely populate working directory.
-It uses skip-worktree bit (see linkgit:git-update-index[1]) to tell
-Git whether a file on working directory is worth looking at.
+"Sparse checkout" allows populating the working directory sparsely.
+It uses the skip-worktree bit (see linkgit:git-update-index[1]) to tell
+Git whether a file in the working directory is worth looking at.
 
-"git read-tree" and other merge-based commands ("git merge", "git
-checkout"...) can help maintaining skip-worktree bitmap and working
+'git read-tree' and other merge-based commands ('git merge', 'git
+checkout'...) can help maintaining the skip-worktree bitmap and working
 directory update. `$GIT_DIR/info/sparse-checkout` is used to
-define the skip-worktree reference bitmap. When "git read-tree" needs
-to update working directory, it will reset skip-worktree bit in index
+define the skip-worktree reference bitmap. When 'git read-tree' needs
+to update the working directory, it resets the skip-worktree bit in the index
 based on this file, which uses the same syntax as .gitignore files.
 If an entry matches a pattern in this file, skip-worktree will be
 set on that entry. Otherwise, skip-worktree will be unset.
@@ -397,18 +397,18 @@ skip-worktree turns from unset to set, it will add the corresponding
 file back. If it turns from set to unset, that file will be removed.
 
 While `$GIT_DIR/info/sparse-checkout` is usually used to specify what
-files are in. You can also specify what files are _not_ in, using
-negate patterns. For example, to remove file "unwanted":
+files are in, you can also specify what files are _not_ in, using
+negate patterns. For example, to remove the file `unwanted`:
 
 ----------------
 *
 !unwanted
 ----------------
 
-Another tricky thing is fully repopulating working directory when you
+Another tricky thing is fully repopulating the working directory when you
 no longer want sparse checkout. You cannot just disable "sparse
-checkout" because skip-worktree are still in the index and you working
-directory is still sparsely populated. You should re-populate working
+checkout" because skip-worktree bits are still in the index and your working
+directory is still sparsely populated. You should re-populate the working
 directory with the `$GIT_DIR/info/sparse-checkout` file content as
 follows:
 
@@ -416,8 +416,8 @@ follows:
 *
 ----------------
 
-Then you can disable sparse checkout. Sparse checkout support in "git
-read-tree" and similar commands is disabled by default. You need to
+Then you can disable sparse checkout. Sparse checkout support in 'git
+read-tree' and similar commands is disabled by default. You need to
 turn `core.sparseCheckout` on in order to have sparse checkout
 support.
 
Signature · 1 line
1.7.7.rc0.469.g9eb94
#16 lore raw

PATCH 3/3 git-read-tree.txt: correct sparse-checkout and skip-worktree description

In reply to Michael J Gruber

The description of .git/info/sparse-checkout and skip-worktree is exactly the opposite of what is true, which is:

If a file matches a pattern in sparse-checkout, then (it is to be checked out and therefore) skip-worktree is unset for that file; otherwise, it is set (so that it is not checked out).

Currently, the opposite is documented, and (consistently) read-tree's behavior with respect to bit flips is descibed incorrectly.

Fix it.

In hindsight, it would have been much better to have a "sparse-ignore" or "sparse-skip" file so that an empty file would mean a full checkout, and the file logic would be analogous to that of .gitignore, excludes and skip-worktree.

---
 Documentation/git-read-tree.txt |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
Documentation/git-read-tree.txt +4 -4
index 0004f4b..1bd0317 100644
@@ -389,12 +389,12 @@ directory update. `$GIT_DIR/info/sparse-checkout` is used to
 define the skip-worktree reference bitmap. When 'git read-tree' needs
 to update the working directory, it resets the skip-worktree bit in the index
 based on this file, which uses the same syntax as .gitignore files.
-If an entry matches a pattern in this file, skip-worktree will be
-set on that entry. Otherwise, skip-worktree will be unset.
+If an entry matches a pattern in this file, skip-worktree will not be
+set on that entry. Otherwise, skip-worktree will be set.
 
 Then it compares the new skip-worktree value with the previous one. If
-skip-worktree turns from unset to set, it will add the corresponding
-file back. If it turns from set to unset, that file will be removed.
+skip-worktree turns from set to unset, it will add the corresponding
+file back. If it turns from unset to set, that file will be removed.
 
 While `$GIT_DIR/info/sparse-checkout` is usually used to specify what
 files are in, you can also specify what files are _not_ in, using
Signature · 1 line
1.7.7.rc0.469.g9eb94
#17 lore raw

Re: [PATCH 3/3] git-read-tree.txt: correct sparse-checkout and skip-worktree description

Quoted 11 lines · Michael J Gruber

The description of .git/info/sparse-checkout and skip-worktree is exactly the opposite of what is true, which is:

If a file matches a pattern in sparse-checkout, then (it is to be checked out and therefore) skip-worktree is unset for that file; otherwise, it is set (so that it is not checked out).

Currently, the opposite is documented, and (consistently) read-tree's behavior with respect to bit flips is descibed incorrectly.

Fix it.

Ack.

Quoted 4 lines

In hindsight, it would have been much better to have a "sparse-ignore" or "sparse-skip" file so that an empty file would mean a full checkout, and the file logic would be analogous to that of .gitignore, excludes and skip-worktree.

.gitignore works towards excluding files. No rule means no excluding. sparse-checkout file works towards including files, no rule means no inclusion.

Signature · 1 line
Duy
#18 lore raw

Re: [PATCH 3/3] git-read-tree.txt: correct sparse-checkout and skip-worktree description

Nguyen Thai Ngoc Duy venit, vidit, dixit 21.09.2011 11:26:

Quoted 16 lines
Quoted 11 lines · Michael J Gruber

The description of .git/info/sparse-checkout and skip-worktree is exactly the opposite of what is true, which is:

If a file matches a pattern in sparse-checkout, then (it is to be checked out and therefore) skip-worktree is unset for that file; otherwise, it is set (so that it is not checked out).

Currently, the opposite is documented, and (consistently) read-tree's behavior with respect to bit flips is descibed incorrectly.

Fix it.

Ack.

Quoted 8 lines
Quoted 4 lines

In hindsight, it would have been much better to have a "sparse-ignore" or "sparse-skip" file so that an empty file would mean a full checkout, and the file logic would be analogous to that of .gitignore, excludes and skip-worktree.

.gitignore works towards excluding files. No rule means no excluding. sparse-checkout file works towards including files, no rule means no inclusion.

Sure, but with a "sparse-skip" rather than "sparse-checkout", we would not even need an additional config variable, and the skip-worktree centered explanations would follow the same logic (no need for the additional negation) as the ignore files and the new sparse-skip file. Also, I'm not sure whether more sparse users say "I want only that subdir." than "I don't want that subdir."

But it's there to stay, of course.

Cheers,
Michael

#19 lore raw

Re: [PATCH 3/3] git-read-tree.txt: correct sparse-checkout and skip-worktree description

Quoted 5 lines · Michael J Gruber
Quoted 5 lines
Quoted 4 lines

In hindsight, it would have been much better to have a "sparse-ignore" or "sparse-skip" file so that an empty file would mean a full checkout, and the file logic would be analogous to that of .gitignore, excludes and skip-worktree.

Quoted 8 lines
Quoted 3 lines

.gitignore works towards excluding files. No rule means no excluding. sparse-checkout file works towards including files, no rule means no inclusion.

Sure, but with a "sparse-skip" rather than "sparse-checkout", we would not even need an additional config variable, and the skip-worktree centered explanations would follow the same logic (no need for the additional negation) as the ignore files and the new sparse-skip file.

I'll kill that config variable some day when sparse checkout code has no overhead over normal case ("include all").

Signature · 1 line
Duy
#20 lore raw

cover read-tree cleanups

In reply to Michael J Gruber

These are a few cleanups I noticed while checking Joshua's sparse checkout problem when swithcing branches with a dirty sparse tree.
They are independent of a possible fix.

Michael J Gruber (3):
unpack-trees: print "Aborting" to stderr git-read-tree.txt: language and typography fixes git-read-tree.txt: correct sparse-checkout and skip-worktree
description

 Documentation/git-read-tree.txt |   48 +++++++++++++++++++-------------------
 unpack-trees.c                  |    2 +-
 2 files changed, 25 insertions(+), 25 deletions(-)
Signature · 1 line
1.7.7.rc0.469.g9eb94
#21 lore raw

Re: [PATCH 0/3] read-tree cleanups

Michael J Gruber venit, vidit, dixit 21.09.2011 09:48:

Quoted 10 lines

These are a few cleanups I noticed while checking Joshua's sparse checkout problem when swithcing branches with a dirty sparse tree.
They are independent of a possible fix.

Michael J Gruber (3):
unpack-trees: print "Aborting" to stderr git-read-tree.txt: language and typography fixes git-read-tree.txt: correct sparse-checkout and skip-worktree
description

Quoted 4 lines
 Documentation/git-read-tree.txt |   48 +++++++++++++++++++-------------------
 unpack-trees.c                  |    2 +-
 2 files changed, 25 insertions(+), 25 deletions(-)

Uhm, I forgot about the dont-cc-jc-in-rc policy, sorry. This is not a late-minute regression fix and can wait.

Michael

#22 lore raw

Re: [PATCH 0/3] read-tree cleanups

Quoted 2 lines · Michael J Gruber

Uhm, I forgot about the dont-cc-jc-in-rc policy, sorry. This is not a late-minute regression fix and can wait.

Thanks but that is not a policy; merely my preference. It also is a bit unnecessarily stronger than my actual preferences, which is

(1) I do not want to see a patch sent "To:" me as the maintainer the first round of a new, undiscussed patch, as if it is ready for inclusion, at any time, not just during rc.

(2) I do appreciate a patch sent "Cc:" me as a member of the development community patches for discussion, especially to areas in which I am an area expert, at any time, including during rc.