From: Phillip Wood <phillip.wood123@gmail.com>
To: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>,
Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: Support for --stdin-paths in commit, add, etc
Date: Thu, 1 Aug 2019 18:35:26 +0100 [thread overview]
Message-ID: <06daa8c1-d955-1e49-e5e6-85d53ffce6e6@gmail.com> (raw)
In-Reply-To: <ab333992-35c6-a5a9-0bcb-cef51f004679@syntevo.com>
On 01/08/2019 14:25, Alexandr Miloslavskiy wrote:
> On 31.07.2019 19:19, Jeff King wrote:
>> I don't have any real objection to adding stdin support for more
>> commands. Bu tin the specific case you're discussing, it seems like
>> using "git update-index" might already solve your problem. It's the
>> intended plumbing for scripted index updates, and it already supports
>> receiving paths from stdin.
>
> I have now studied which git commands already use commandline splitting
> in our application. For some of them, I didn't find comparable plumbing;
> for others, I feel that a lot of new edge cases will arise, and it will
> need a lot of testing to make sure things work as expected.
>
> Therefore, for us it would be best if high-level commands also accepted
> --stdin-paths. If I develop good enough patches for that, will you
> accept them?
>
> We're interested in these high-level commands:
> 1) git add
> 2) git rm
> 3) git checkout
> 4) git reset
> 5) git stash
> 6) git commit
>
> Here's the list of detailed commands and plumbings I found:
> 01) git add
> 'git update-index' doesn't seem to be able to skip ignored files.
No but it only takes paths not pathspecs, can you filter out the ignored
paths first? From a UI point of view it would be better not to allow
users to select ignored files if you don't want to be able to add them.
If you want to use a pathspec then you can do 'git ls-files
--exclude-standard -o -z <pathspec ...> | git update-index --add -z --stdin'
git check-ignore --stdin should help if you have a list of paths and you
want to remove the ignored ones (it's not great as it tells you which
ones are ignored rather than filtering the list for you)
> 02) git add --force
> Probably 'git update-index --add --stdin'.
> 03) git checkout
> Probably 'git checkout-index --stdin'
> 04) git checkout HEAD
> Didn't find a plumbing to only affect named paths.
You can use a temporary index and do
GIT_INDEX_FILE=$tmp_index git read-tree HEAD &&
GIT_INDEX_FILE=$tmp_index git checkout-index --stdin &&
rm $tmp_index
> 05) git checkout --ours
> Probably 'git checkout-index --stage=2 --force --stdin'
> 06) git checkout --theirs
> Probably 'git checkout-index --stage=3 --force --stdin'
> 07) git rm [--force] [--cached]
> Probably 'git update-index --force-remove'
> Didn't find how to delete files from working tree.
You have to delete them yourself.
> 08) git reset -q HEAD
> Didn't find a plumbing to only affect named paths.
It's a bit of a pain but you can use 'git update-index -q --unmerged
--refresh && git diff-index --cached -z HEAD' to get a list of paths in
the index that differ from HEAD. The list contains the old oid for each
path (see the man page for the format) and you can feed those into 'git
update-index --index-info' to update the index.
> 09) git add --update
> Probably 'git update-index --again --add --stdin'
> Not sure that --again is good replacement.
or something like 'git update-index -q --refresh && git diff-files
--name-only -z | git update-index -z --stdin'
> 10) git stash push [--keep-index] [--include-untracked] [--message]
> Didn't find plumbing for stashes.
stashes are just commits really so there are no plumbing commands
specifically related to them.
> 11) git commit [--allow-empty] [--amend] [--signoff] [--no-verify]
> --file=CommitMessage.txt -o
> Didn't find a plumbing to only affect named staged paths.
You can use a temporary index, add the files you want to commit with
update-index --stdin and then run 'git commit'
When I've been scripting I've sometimes wished that diff-index and
diff-files had a --stdin option.
Best Wishes
Phillip
next prev parent reply other threads:[~2019-08-01 17:35 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 15:45 Support for --stdin-paths in commit, add, etc Alexandr Miloslavskiy
2019-07-31 17:15 ` Junio C Hamano
2019-07-31 17:19 ` Jeff King
2019-07-31 21:21 ` Junio C Hamano
2019-08-01 13:25 ` Alexandr Miloslavskiy
2019-08-01 17:35 ` Phillip Wood [this message]
2019-08-01 20:26 ` Junio C Hamano
2019-08-01 20:40 ` Alexandr Miloslavskiy
2019-08-02 11:33 ` Johannes Schindelin
2019-08-02 11:45 ` Alexandr Miloslavskiy
2019-08-02 14:48 ` Johannes Schindelin
2019-08-02 14:52 ` Alexandr Miloslavskiy
2019-08-02 11:52 ` Alexandr Miloslavskiy
2019-08-02 14:47 ` Johannes Schindelin
2019-08-02 15:11 ` Alexandr Miloslavskiy
2019-08-01 14:26 ` René Scharfe
2019-08-01 14:33 ` Alexandr Miloslavskiy
2019-08-01 15:56 ` Junio C Hamano
2019-08-01 16:04 ` Alexandr Miloslavskiy
2019-08-01 20:45 ` Junio C Hamano
2019-08-01 20:51 ` Alexandr Miloslavskiy
2019-08-02 11:40 ` Johannes Schindelin
2019-08-02 11:44 ` Alexandr Miloslavskiy
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=06daa8c1-d955-1e49-e5e6-85d53ffce6e6@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=alexandr.miloslavskiy@syntevo.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).