Re: [PATCH 5/5] Enable ref log creation in git checkout -b.

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

Re: [PATCH 5/5] Enable ref log creation in git checkout -b.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:27

Shawn Pearce [off-list ref] writes:
Junio C Hamano [off-list ref] wrote:
quoted
I've swallowed all 10 and pushed them out in "pu", but could you
add tests to check the Porcelainish commands you touched with
this series to make sure they all log correctly?
Sure.  I've been putting it off as I've been busy the past few days
and have also been thinking about trying to rebuild reflog using a
tag/annotation branch style, which might be more generally useful
to others.
It appears that there is more serious breakage caused by the
lock_ref change.  http-fetch in "next" fails to clone, because
the call to lock-ref-sha1 in fetch.c::pull() forgets that the
program might be creating a new ref.

Another breakage I found (not related to ref-log) is that it
appears fetch.c, even in "master" branch [*1*], has current_ref
variable and does things depending on it, but nobody seems to
set that variable, so there are a lot of dead code that looks as
if they are doing something useful, enclosed in sections like:

	if (somethingelse && current_ref) {
        	dead code
	}

I'll probably revert the ref-log series from "next" in the next
round of updates, while killing the current_ref variable from
"master".


[Footnotes]

*1* It actually is worse than that.  Commit cd541a6 introduced
this variable but nobody touches it ever in the development
history of that variable.  I wonder what the original author and
the maintainer were smoking back then...

Re: [PATCH 5/5] Enable ref log creation in git checkout -b.

From: Shawn Pearce <hidden>
Date: 2016-06-15 22:42:27

Junio C Hamano [off-list ref] wrote:
Shawn Pearce [off-list ref] writes:
quoted
Junio C Hamano [off-list ref] wrote:
quoted
I've swallowed all 10 and pushed them out in "pu", but could you
add tests to check the Porcelainish commands you touched with
this series to make sure they all log correctly?
Sure.  I've been putting it off as I've been busy the past few days
and have also been thinking about trying to rebuild reflog using a
tag/annotation branch style, which might be more generally useful
to others.
It appears that there is more serious breakage caused by the
lock_ref change.  http-fetch in "next" fails to clone, because
the call to lock-ref-sha1 in fetch.c::pull() forgets that the
program might be creating a new ref.
Hmm.  I thought I was doing the same thing fetch used to do which
appeared to only work on refs which already exist, and not creating
new refs...
 
Another breakage I found (not related to ref-log) is that it
appears fetch.c, even in "master" branch [*1*], has current_ref
variable and does things depending on it, but nobody seems to
set that variable, so there are a lot of dead code that looks as
if they are doing something useful, enclosed in sections like:

	if (somethingelse && current_ref) {
        	dead code
	}
 
I wondered about that code...

-- 
Shawn.

Re: [PATCH 5/5] Enable ref log creation in git checkout -b.

From: Shawn Pearce <hidden>
Date: 2016-06-15 22:42:27

Junio C Hamano [off-list ref] wrote:
Shawn Pearce [off-list ref] writes:
quoted
Junio C Hamano [off-list ref] wrote:
quoted
I've swallowed all 10 and pushed them out in "pu", but could you
add tests to check the Porcelainish commands you touched with
this series to make sure they all log correctly?
Sure.  I've been putting it off as I've been busy the past few days
and have also been thinking about trying to rebuild reflog using a
tag/annotation branch style, which might be more generally useful
to others.
It appears that there is more serious breakage caused by the
lock_ref change.  http-fetch in "next" fails to clone, because
the call to lock-ref-sha1 in fetch.c::pull() forgets that the
program might be creating a new ref.
The breakage is because of current_ref always being null.  The old
code would allow locking a non-existant ref in this case while the
new code was failing.  A simple change such as the following should
fix it:

-->8--
Fix fetch when using reflog.

Previously fetch was permitted to create refs if they did not exist;
this only worked as current_ref was always NULL and thus never
would get compared against the existing ref.

Signed-off-by: Shawn O. Pearce <redacted>

---

2dad4178db978c01257fde949d808361589ee003
 fetch.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

2dad4178db978c01257fde949d808361589ee003
diff --git a/fetch.c b/fetch.c
index fd57684..15110b8 100644
--- a/fetch.c
+++ b/fetch.c
@@ -213,7 +213,7 @@ int pull(char *target)
 	save_commit_buffer = 0;
 	track_object_refs = 0;
 	if (write_ref) {
-		lock = lock_ref_sha1(write_ref, current_ref, 1);
+		lock = lock_ref_sha1(write_ref, current_ref, 0);
 		if (!lock) {
 			error("Can't lock ref %s", write_ref);
 			return -1;
-- 
1.3.3.gfad60
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help