From: Junio C Hamano <gitster@pobox.com>
To: Sundararajan R <dyoucme@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] [GSoC Microproject]Adding "-" shorthand for "@{-1}" in RESET command
Date: Sun, 08 Mar 2015 14:59:09 -0700 [thread overview]
Message-ID: <xmqqpp8j882a.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <loom.20150308T120618-983@post.gmane.org> (Sundararajan R.'s message of "Sun, 8 Mar 2015 11:09:45 +0000 (UTC)")
Sundararajan R <dyoucme@gmail.com> writes:
> I am sorry for the mistakes in the code formatting. It was because I was in
> a hurry that day and I wanted to submit a working patch.
No need to apologize for mistakes. Mistakes are expected part of
being human and the review process is designed to catch exactly
that.
The development is not a race to see who gets there first. It is a
collaborative process to get to a better place together. Once you
got something "working", stop and review your work to see if your
definition of "working" is sensible. Is there a corner case you
missed? Is the code formatted in a similar way as the existing code
around the area you are touching? Are there better ways to do what
you did? Take your time to make sure you would be happy with what
you are sending out.
> In the new patch I
> am making, I am using check_filename() to see if there are files named "-"
> and "@{-1}" in the working tree . Is this an appropriate way to check or is
> there something else suggested?
I think you are making it unnecessarily hard. With your patch, the
code would look like this:
if (argv[0]) {
+ if (!strcmp(argv[0], "-") && !argv[1]) /* "-" is the only argument */
+ {
+ argv[0]="@{-1}";
+ flag=1;
+ }
if (!strcmp(argv[0], "--")) {
argv++; /* reset to HEAD, possibly with paths */
} else if (argv[1] && !strcmp(argv[1], "--")) {
rev = argv[0];
argv += 2;
}
/*
* Otherwise, argv[0] could be either <rev> or <paths> and
* has to be unambiguous. If there is a single argument, it
* can not be a tree
*/
else if ((!argv[1] && !get_sha1_committish(argv[0], unused)) ||
(argv[1] && !get_sha1_treeish(argv[0], unused))) {
/*
* Ok, argv[0] looks like a commit/tree; it should not
* be a filename.
*/
verify_non_filename(prefix, argv[0]);
rev = *argv++;
} else {
/* Otherwise we treat this as a filename */
+ if(flag)
+ argv[0]="-";
verify_filename(prefix, argv[0], 1);
}
}
I was wondering what you are passing to verify_non_filename() that
you did not touch. It would see "@{-1}", try to make sure that the
working tree does not have a file with that name, and if there is
the end user would be warned about ambiguity.
If the user typed "git reset @{-1}", then that warning is very
sensible, but when the end user only typed "git reset -", is there
any ambiguity?
next prev parent reply other threads:[~2015-03-08 21:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-08 11:09 [PATCH] [GSoC Microproject]Adding "-" shorthand for "@{-1}" in RESET command Sundararajan R
2015-03-08 21:59 ` Junio C Hamano [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-03-07 1:57 Sundararajan R
2015-03-08 7:34 ` 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=xmqqpp8j882a.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=dyoucme@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.