Re: [PATCH 4/4] create_symref: use existing ref-lock code
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 21, 2015, 20:50 UTC
- Message-ID
- <xmqq8u4nfrvv.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20151220073414.GD30662@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> #ifndef NO_SYMLINK_HEAD
> - if (prefer_symlink_refs) {
> - unlink(ref_path);
> - if (!symlink(target, ref_path))
> - goto done;I see that the original was sloppy (most certainly my bad) ...
> + char *ref_path = get_locked_file_path(lock->lk); > + unlink(ref_path);
... and you inherited that. I see a few seemingly related helpers in wrapper.c, but none looks useful in this context X-<.
if (unlink_or_warn(ref_path))
return -1;is close enough, but it still lets the caller fallback to textual symref.
Show 17 quoted lines
> + ret = symlink(target, ref_path); > + free(ref_path); > + > + if (ret) > fprintf(stderr, "no symlink - falling back to symbolic ref\n"); > - } > #endif > + return ret; > +} > > - len = snprintf(buf, sizeof(buf), "ref: %s\n", target); > -... > - free(lockpath); > - > -#ifndef NO_SYMLINK_HEAD > - done: > -#endif
This huge block is worth removing ;-) Thanks.