From: Junio C Hamano <gitster@pobox•com>
To: Duy Nguyen <pclouds@gmail•com>
Cc: Git Mailing List <git@vger•kernel.org>,
Max Kirillov <max@max630•net>,
Eric Sunshine <sunshine@sunshineco•com>,
Michael Haggerty <mhagger@alum•mit.edu>
Subject: Re: [PATCH 3/5] checkout --to: no auto-detach if the ref is already checked out
Date: Thu, 24 Jul 2014 09:39:51 -0700 [thread overview]
Message-ID: <xmqqr41aaey0.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CACsJy8CTYyjqmwGgkKZQFX4YC9-X=TGx9Ex5QfNWRNKFjgpKag@mail.gmail.com> (Duy Nguyen's message of "Thu, 24 Jul 2014 17:09:28 +0700")
Duy Nguyen <pclouds@gmail•com> writes:
> On Thu, Jul 24, 2014 at 4:16 AM, Junio C Hamano <gitster@pobox•com> wrote:
>>> + if (strbuf_read_file(&sb, path.buf, 0) <= 0 ||
>>> + !skip_prefix(sb.buf, "ref:", &start))
>>> + goto done;
>>> while (isspace(*start))
>>> start++;
>>> end = start;
>>> while (*end && !isspace(*end))
>>> end++;
>>
>> Not new in this round of update, and may not even be an issue, but:
>>
>> - Earlier, the code returned early on a negative return value from
>> read-file (i.e., an error), but this round it also does so for
>> zero. Intended?
>
> Yes. But it does not make any difference. strbuf_read_file returns
> sb.len, if it's empty, the next skip_prefix would fail anyway.
Yes but changing < 0 to <= 0 is inconsistent with that; I would
understand if you changed it to <= 4, which would be consistent with
the reasoning, though.
>> The code in the patch, which is something in between, does not make
>> much sense to me.
>
> I think more about "echo abc > $this_file" where the echo command may
> output '\r\n' on Windows (wild guess though, I don't use Windows
> much). I think I'm going with _rtrim.
To expect 'echo' into the file is to expect and encourage that
people muck with the internal implementation details by hand, which
we do not generally do for things inside .git [*1*].
If we consider the contents of $this_file not an implementation
detail but a part of the published API (i.e. "writing this string
into the file is a valid way to make Git do this"), rtrim would at
least be consistent with how the existing code deals with symrefs,
so I wouldn't say "does not make much sense" if you are going in
that direction ;-)
[Footnote]
*1* ... except for .git/config, to which we say "It's a simple text
file; don't be afraied to edit it away!".
next prev parent reply other threads:[~2014-07-24 16:40 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-23 11:43 [PATCH 0/5] nd/multiple-work-trees follow-ups Nguyễn Thái Ngọc Duy
2014-07-23 11:43 ` [PATCH 1/5] gitrepository-layout.txt: s/ignored/ignored if/ Nguyễn Thái Ngọc Duy
2014-07-23 11:43 ` [PATCH 2/5] prune --repos: fix uninitialized access Nguyễn Thái Ngọc Duy
2014-07-23 19:59 ` Junio C Hamano
2014-07-24 10:14 ` Duy Nguyen
2014-07-23 11:43 ` [PATCH 3/5] checkout --to: no auto-detach if the ref is already checked out Nguyễn Thái Ngọc Duy
2014-07-23 13:48 ` Michael J Gruber
2014-07-23 17:46 ` Junio C Hamano
2014-07-24 9:58 ` Duy Nguyen
2014-07-24 21:30 ` Junio C Hamano
2014-07-25 6:51 ` Michael J Gruber
2014-07-30 18:03 ` Junio C Hamano
2014-07-30 18:52 ` Junio C Hamano
2014-08-27 11:58 ` Duy Nguyen
2014-08-27 16:08 ` Junio C Hamano
2014-07-23 21:16 ` Junio C Hamano
2014-07-24 10:09 ` Duy Nguyen
2014-07-24 16:39 ` Junio C Hamano [this message]
2014-07-24 18:13 ` Junio C Hamano
2014-07-23 11:43 ` [PATCH 4/5] checkout --to: fix dangling pointers in remove_junk() Nguyễn Thái Ngọc Duy
2014-07-23 11:43 ` [PATCH 5/5] environment.c: fix incorrect git_graft_file initialization Nguyễn Thái Ngọc Duy
2014-07-23 21:22 ` Junio C Hamano
2014-07-29 13:50 ` [PATCH v2 0/8] nd/multiple-work-trees follow-ups Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 1/8] gitrepository-layout.txt: s/ignored/ignored if/ Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 2/8] checkout: no need to call check_linked_checkouts if head_ref is NULL Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 3/8] prune --repos: fix uninitialized access Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 4/8] checkout: no auto-detach if the ref is already checked out Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 5/8] checkout --to: fix dangling pointers in remove_junk() Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 6/8] environment.c: fix incorrect git_graft_file initialization Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 7/8] checkout: prefix --to argument properly when cwd is moved Nguyễn Thái Ngọc Duy
2014-07-29 20:51 ` Junio C Hamano
2014-07-30 10:32 ` Duy Nguyen
2014-07-29 13:50 ` [PATCH v2 8/8] checkout --to: do not touch existing target directory Nguyễn Thái Ngọc Duy
2014-07-30 17:51 ` [PATCH 0/5] nd/multiple-work-trees follow-ups Junio C Hamano
2014-07-31 10:13 ` Duy Nguyen
2014-07-31 17:00 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqr41aaey0.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=max@max630$(echo .)net \
--cc=mhagger@alum$(echo .)mit.edu \
--cc=pclouds@gmail$(echo .)com \
--cc=sunshine@sunshineco$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox