Re: [PATCH 0/6] Initial subproject support (RFC?)

5 messages, 5 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 0/6] Initial subproject support (RFC?)

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:03

Linus Torvalds [off-list ref] writes:
On Tue, 10 Apr 2007, Junio C Hamano wrote:
quoted
Well, I was planning to apply this directly on 'master' after
giving them another pass.
Goodie. I gave them another pass myself, and noticed a small leak and a 
stupid copy-paste problem, fixed thus..
Yeah, I noticed the first one but not the second.  Thanks.
quoted hunk
diff --git a/read-cache.c b/read-cache.c
index 8fe94cd..f458f50 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -279,7 +279,7 @@ int base_name_compare(const char *name1, int len1, int mode1,
 	c2 = name2[len];
 	if (!c1 && (S_ISDIR(mode1) || S_ISDIRLNK(mode1)))
 		c1 = '/';
-	if (!c2 && (S_ISDIR(mode2) || S_ISDIRLNK(mode1)))
+	if (!c2 && (S_ISDIR(mode2) || S_ISDIRLNK(mode2)))
 		c2 = '/';
 	return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;
 }
diff --git a/refs.c b/refs.c
index 229da74..11a67a8 100644
--- a/refs.c
+++ b/refs.c
@@ -229,6 +229,7 @@ static int resolve_gitlink_packed_ref(char *name, int pathlen, const char *refna
 	if (!f)
 		return -1;
 	read_packed_refs(f, &refs);
+	fclose(f);
 	ref = refs.packed;
 	retval = -1;
 	while (ref) {
By the way,...

People occasionally ask "how would I make a small fix to a
commit that is buried in the history", so let me take a moment
to give them a recipe.

Let's say while reviewing the code after applying all of the
6-series, you noticed the above thinko.  First find out which
commit caused it:

$ git checkout lt/gitlink
$ git blame -L229,+7 master.. -- refs.c
b60108a1 (Linus Torvalds 2007-04-09 21:14:26 -0700 229) 	if (!f)
b60108a1 (Linus Torvalds 2007-04-09 21:14:26 -0700 230) 		re..
b60108a1 (Linus Torvalds 2007-04-09 21:14:26 -0700 231) 	read_packe..
b60108a1 (Linus Torvalds 2007-04-09 21:14:26 -0700 232) 	ref = refs..
b60108a1 (Linus Torvalds 2007-04-09 21:14:26 -0700 233) 	retval = -..
b60108a1 (Linus Torvalds 2007-04-09 21:14:26 -0700 234) 	while (ref..
b60108a1 (Linus Torvalds 2007-04-09 21:14:26 -0700 235) 		if..

The commit to fix is b60108a1 (this is what I have in my private
repo, and I'll be rebuilding the series with this example, so
you will never see this commit object name in the end result
I'll be pushing out).  So I detach the HEAD at that commit and
make a fix:

$ git checkout b60108a1
$ edit refs.c
$ git diff; # just to make sure
$ git commit -a --amend

At this point, the detached HEAD and the original branch look
like this:

$ git show-branch lt/gitlink HEAD
! [lt/gitlink] Teach core object handling functions about gitlinks
 * [HEAD] Add 'resolve_gitlink_ref()' helper function
--
 * [HEAD] Add 'resolve_gitlink_ref()' helper function
+  [lt/gitlink] Teach core object handling functions about gitlinks
+  [lt/gitlink^] Teach "fsck" not to follow subproject links
+  [lt/gitlink~2] Add "S_IFDIRLNK" file mode infrastructure for git links
+  [lt/gitlink~3] Add 'resolve_gitlink_ref()' helper function
+* [HEAD^] Avoid overflowing name buffer in deep directory structures

We fixed lt/gitlink~3 and the fixed-up commit is at HEAD.  We
want to rebase the rest of lt/gitlink on top of HEAD, like this:

$ git rebase HEAD lt/gitlink

This will take us back on lt/gitlink branch, set the tip of the
branch to the commit we just made with the fix-up, and the first
round will try to apply the change lt/gitlink~3 brings in on top
of our HEAD.  This _will_ fail, but that is to be expected, as
we intend to replace that with what we just amended.  Just reset
it away and keep going.

$ git reset --hard
$ git rebase --skip

Dealing with the other one in read-cache.c can be handled
similarly after this. Luckily blame finds out that it is the
last in the series (i.e. at the tip of lt/gitlink branch), so
usual "fix the topmost commit" procedure applies.

$ edit read-cache.c
$ git diff ;# checking...
$ git commit -a --amend

Re: [PATCH 0/6] Initial subproject support (RFC?)

From: Nicolas Pitre <hidden>
Date: 2016-06-15 22:43:03

On Tue, 10 Apr 2007, Junio C Hamano wrote:
By the way,...

People occasionally ask "how would I make a small fix to a
commit that is buried in the history", so let me take a moment
to give them a recipe.
This is definitively good Documentation/howto/ material.


Nicolas

Re: [PATCH 0/6] Initial subproject support (RFC?)

From: Sam Ravnborg <hidden>
Date: 2016-06-15 22:43:03

On Tue, Apr 10, 2007 at 01:52:46PM -0700, Junio C Hamano wrote:
People occasionally ask "how would I make a small fix to a
commit that is buried in the history", so let me take a moment
to give them a recipe.
That recipe looks ummm complicated...
What I usually do is:

git format-patch HEAD~4..HEAD
git reset --hard HAED~4
patch -p1 < 0004*
...edit...
delete diff from 0004*
git diff >> 0004*
git reset --hard
git am 000*


Maybe this is as complicated as your example but this
is very simple to deal with.
And I do not destroy history or anything.

But that said I do not use topic brances but simply
clone my local repository as needed.
And I always deal with a linear history.


[I post this mostly to check if this is insane
and I need to understand the way you propose to do stuff]

	Sam

Re: [PATCH 0/6] Initial subproject support (RFC?)

From: David Kågedal <hidden>
Date: 2016-06-15 22:43:03

Junio C Hamano [off-list ref] writes:
$ git rebase HEAD lt/gitlink

This will take us back on lt/gitlink branch, set the tip of the
branch to the commit we just made with the fix-up, and the first
round will try to apply the change lt/gitlink~3 brings in on top
of our HEAD.  This _will_ fail, but that is to be expected, as
we intend to replace that with what we just amended.  Just reset
it away and keep going.

$ git reset --hard
$ git rebase --skip
Wouldn't

$ git rebase --onto HEAD lt/gitlink~3 lt/gitlink

do the trick in one step?

-- 
David Kågedal

Re: [PATCH 0/6] Initial subproject support (RFC?)

From: J. Bruce Fields <hidden>
Date: 2016-06-15 22:43:04

On Tue, Apr 10, 2007 at 05:03:13PM -0400, Nicolas Pitre wrote:
This is definitively good Documentation/howto/ material.
There's actually something similar already in "modifying a single
commit" in the "user manual":

http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#id276844

But it uses a throw-away branch instead of the detached head, and uses
rebase --onto instead of rebasing and then --skip'ing.

--b.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help