* Re: [BUG] Git-GUI destroys the author name
From: bitjo @ 2016-12-12 20:59 UTC (permalink / raw)
To: git
In-Reply-To: <588ac268-0a1b-6787-e6a1-4164e7e9a784@b-i-t.de>
Addition to the bug
Proposal
https://github.com/git-for-windows/git/commit/30395c645adf21828bbccbdcd3c5c36c39f07050
should be considered and possibly implemented.
But as described in
https://github.com/git-for-windows/git/issues/761#issuecomment-221057828.
And then an implementation without regression is necessary.
^ permalink raw reply
* Re: [PATCHv2 5/7] versioncmp: cope with common part overlapping with prerelease suffix
From: Junio C Hamano @ 2016-12-12 21:27 UTC (permalink / raw)
To: SZEDER Gábor
Cc: Jeff King, Nguyễn Thái Ngọc Duy, Leho Kraav, git
In-Reply-To: <20161208142401.1329-6-szeder.dev@gmail.com>
SZEDER Gábor <szeder.dev@gmail.com> writes:
> diff --git a/versioncmp.c b/versioncmp.c
> index a55c23ad5..f86ac562e 100644
> --- a/versioncmp.c
> +++ b/versioncmp.c
> @@ -26,12 +26,15 @@ static int initialized;
>
> /*
> * off is the offset of the first different character in the two strings
> - * s1 and s2. If either s1 or s2 contains a prerelease suffix starting
> - * at that offset, it will be forced to be on top.
> + * s1 and s2. If either s1 or s2 contains a prerelease suffix containing
> + * that offset, then that string will be forced to be on top.
> *
> - * If both s1 and s2 contain a (different) suffix at that position,
> + * If both s1 and s2 contain a (different) suffix around that position,
> * their order is determined by the order of those two suffixes in the
> * configuration.
> + * If any of the strings contains more than one different suffixes around
> + * that position, then that string is sorted according to the contained
> + * suffix which comes first in the configuration.
> *
> * Return non-zero if *diff contains the return value for versioncmp()
> */
> @@ -44,10 +47,21 @@ static int swap_prereleases(const char *s1,
>
> for (i = 0; i < prereleases->nr; i++) {
> const char *suffix = prereleases->items[i].string;
> - if (i1 == -1 && starts_with(s1 + off, suffix))
> - i1 = i;
> - if (i2 == -1 && starts_with(s2 + off, suffix))
> - i2 = i;
> + int j, start, suffix_len = strlen(suffix);
> + if (suffix_len < off)
> + start = off - suffix_len + 1;
> + else
> + start = 0;
Now that this function has to rewind the beginning of the comparison
earlier than the given 'off', it makes me wonder if it still makes
sense for the caller to compute it in the first place.
> + for (j = start; j <= off; j++)
> + if (i1 == -1 && starts_with(s1 + j, suffix)) {
> + i1 = i;
> + break;
> + }
> + for (j = start; j <= off; j++)
> + if (i2 == -1 && starts_with(s2 + j, suffix)) {
> + i2 = i;
> + break;
> + }
> }
> if (i1 == -1 && i2 == -1)
> return 0;
^ permalink raw reply
* What's cooking in git.git (Dec 2016, #02; Mon, 12)
From: Junio C Hamano @ 2016-12-12 21:30 UTC (permalink / raw)
To: git
Here are the topics that have been cooking. Commits prefixed with
'-' are only in 'pu' (proposed updates) while commits prefixed with
'+' are in 'next'. The ones marked with '.' do not appear in any of
the integration branches, but I am still holding onto them.
Quite a many topics that have been waiting before the most recent
release have now been merged to 'next'; hopefully they will be ready
for 'master' in a week or two.
You can find the changes described here in the integration branches
of the repositories listed at
http://git-blame.blogspot.com/p/git-public-repositories.html
--------------------------------------------------
[New Topics]
* jc/lock-report-on-error (2016-12-07) 3 commits
- lockfile: LOCK_REPORT_ON_ERROR
- hold_locked_index(): align error handling with hold_lockfile_for_update()
- wt-status: implement opportunisitc index update correctly
Git 2.11 had a minor regression in "merge --ff-only" that competed
with another process that simultanously attempted to update the
index. We used to explain what went wrong with an error message,
but the new code silently failed. This resurrects the error
message.
Will merge to 'next'.
* nd/shallow-fixup (2016-12-07) 6 commits
- shallow.c: remove useless code
- shallow.c: bit manipulation tweaks
- shallow.c: avoid theoretical pointer wrap-around
- shallow.c: make paint_alloc slightly more robust
- shallow.c: stop abusing COMMIT_SLAB_SIZE for paint_info's memory pools
- shallow.c: rename fields in paint_info to better express their purposes
Code cleanup in shallow boundary computation.
Will merge to 'next'.
* sb/sequencer-abort-safety (2016-12-09) 5 commits
- sequencer: remove useless get_dir() function
- sequencer: make sequencer abort safer
- t3510: test that cherry-pick --abort does not unsafely change HEAD
- am: change safe_to_abort()'s not rewinding error into a warning
- am: fix filename in safe_to_abort() error message
Unlike "git am --abort", "git cherry-pick --abort" moved HEAD back
to where cherry-pick started while picking multiple changes, when
the cherry-pick stopped to ask for help from the user, and the user
did "git reset --hard" to a different commit in order to re-attempt
the operation.
Will merge to 'next'.
* kh/tutorial-grammofix (2016-12-09) 4 commits
- doc: omit needless "for"
- doc: make the intent of sentence clearer
- doc: add verb in front of command to run
- doc: add articles (grammar)
Will merge to 'next'.
* da/mergetool-xxdiff-hotkey (2016-12-11) 1 commit
- mergetools: fix xxdiff hotkeys
The way to specify hotkeys to "xxdiff" that is used by "git
mergetool" has been modernized to match recent versions of xxdiff.
Will merge to 'next'.
* jk/difftool-in-subdir (2016-12-11) 4 commits
- difftool: rename variables for consistency
- difftool: chdir as early as possible
- difftool: sanitize $workdir as early as possible
- difftool: fix dir-diff index creation when in a subdirectory
Even though an fix was attempted in Git 2.9.3 days, but running
"git difftool --dir-diff" from a subdirectory never worked. This
has been fixed.
Will merge to 'next'.
* js/mingw-isatty (2016-12-11) 1 commit
(merged to 'next' on 2016-12-12 at 60c1da6676)
+ mingw: intercept isatty() to handle /dev/null as Git expects it
We often decide if a session is interactive by checking if the
standard I/O streams are connected to a TTY, but isatty() emulation
on Windows incorrectly returned true if it is used on NUL (i.e. an
equivalent to /dev/null). This has been fixed.
Will merge to 'master'.
* ew/svn-fixes (2016-12-12) 2 commits
(merged to 'next' on 2016-12-12 at 91ed5b3cf3)
+ git-svn: document useLogAuthor and addAuthorFrom config keys
+ git-svn: allow "0" in SVN path components
Will merge to 'master'.
* lr/doc-fix-cet (2016-12-12) 1 commit
- date-formats.txt: Typo fix
Will merge to 'next'.
* vs/submodule-clone-nested-submodules-alternates (2016-12-12) 1 commit
- submodule--helper: set alternateLocation for cloned submodules
"git clone --reference $there --recurse-submodules $super" has been
taught to guess repositories usable as references for submodules of
$super that are embedded in $there while making a clone of the
superproject borrow objects from $there; extend the mechanism to
also allow submodules of these submodules to borrow repositories
embedded in these clones of the submodules embedded in the clone of
the superproject.
Will merge to 'next'.
--------------------------------------------------
[Stalled]
* jc/retire-compaction-heuristics (2016-11-02) 3 commits
- SQUASH???
- SQUASH???
- diff: retire the original experimental "compaction" heuristics
Waiting for a reroll.
* jc/abbrev-autoscale-config (2016-11-01) 1 commit
- config.abbrev: document the new default that auto-scales
Waiting for a reroll.
* jk/nofollow-attr-ignore (2016-11-02) 5 commits
- exclude: do not respect symlinks for in-tree .gitignore
- attr: do not respect symlinks for in-tree .gitattributes
- exclude: convert "check_index" into a flags field
- attr: convert "macro_ok" into a flags field
- add open_nofollow() helper
As we do not follow symbolic links when reading control files like
.gitignore and .gitattributes from the index, match the behaviour
and not follow symbolic links when reading them from the working
tree. This also tightens security a bit by not leaking contents of
an unrelated file in the error messages when it is pointed at by
one of these files that is a symbolic link.
Perhaps we want to cover .gitmodules too with the same mechanism?
* nd/worktree-move (2016-11-28) 11 commits
. worktree remove: new command
. worktree move: refuse to move worktrees with submodules
. worktree move: accept destination as directory
. worktree move: new command
. worktree.c: add update_worktree_location()
. worktree.c: add validate_worktree()
. copy.c: convert copy_file() to copy_dir_recursively()
. copy.c: style fix
. copy.c: convert bb_(p)error_msg to error(_errno)
. copy.c: delete unused code in copy_file()
. copy.c: import copy_file() from busybox
(this branch uses nd/worktree-list-fixup; is tangled with sb/submodule-embed-gitdir.)
"git worktree" learned move and remove subcommands.
Reported to break builds on Windows.
* jc/bundle (2016-03-03) 6 commits
- index-pack: --clone-bundle option
- Merge branch 'jc/index-pack' into jc/bundle
- bundle v3: the beginning
- bundle: keep a copy of bundle file name in the in-core bundle header
- bundle: plug resource leak
- bundle doc: 'verify' is not about verifying the bundle
The beginning of "split bundle", which could be one of the
ingredients to allow "git clone" traffic off of the core server
network to CDN.
While I think it would make it easier for people to experiment and
build on if the topic is merged to 'next', I am at the same time a
bit reluctant to merge an unproven new topic that introduces a new
file format, which we may end up having to support til the end of
time. It is likely that to support a "prime clone from CDN", it
would need a lot more than just "these are the heads and the pack
data is over there", so this may not be sufficient.
Will discard.
* mh/connect (2016-06-06) 10 commits
- connect: [host:port] is legacy for ssh
- connect: move ssh command line preparation to a separate function
- connect: actively reject git:// urls with a user part
- connect: change the --diag-url output to separate user and host
- connect: make parse_connect_url() return the user part of the url as a separate value
- connect: group CONNECT_DIAG_URL handling code
- connect: make parse_connect_url() return separated host and port
- connect: re-derive a host:port string from the separate host and port variables
- connect: call get_host_and_port() earlier
- connect: document why we sometimes call get_port after get_host_and_port
Rewrite Git-URL parsing routine (hopefully) without changing any
behaviour.
It has been two months without any support. We may want to discard
this.
* ec/annotate-deleted (2015-11-20) 1 commit
- annotate: skip checking working tree if a revision is provided
Usability fix for annotate-specific "<file> <rev>" syntax with deleted
files.
Has been waiting for a review for too long without seeing anything.
Will discard.
* dk/gc-more-wo-pack (2016-01-13) 4 commits
- gc: clean garbage .bitmap files from pack dir
- t5304: ensure non-garbage files are not deleted
- t5304: test .bitmap garbage files
- prepare_packed_git(): find more garbage
Follow-on to dk/gc-idx-wo-pack topic, to clean up stale
.bitmap and .keep files.
Has been waiting for a reroll for too long.
cf. <xmqq60ypbeng.fsf@gitster.mtv.corp.google.com>
Will discard.
* jc/diff-b-m (2015-02-23) 5 commits
. WIPWIP
. WIP: diff-b-m
- diffcore-rename: allow easier debugging
- diffcore-rename.c: add locate_rename_src()
- diffcore-break: allow debugging
"git diff -B -M" produced incorrect patch when the postimage of a
completely rewritten file is similar to the preimage of a removed
file; such a resulting file must not be expressed as a rename from
other place.
The fix in this patch is broken, unfortunately.
Will discard.
--------------------------------------------------
[Cooking]
* ak/lazy-prereq-mktemp (2016-11-29) 1 commit
(merged to 'next' on 2016-12-12 at f346d1f053)
+ t7610: clean up foo.XXXXXX tmpdir
Test code clean-up.
Will merge to 'master'.
* da/mergetool-trust-exit-code (2016-11-29) 2 commits
(merged to 'next' on 2016-12-12 at 28ae202868)
+ mergetools/vimdiff: trust Vim's exit code
+ mergetool: honor mergetool.$tool.trustExitCode for built-in tools
mergetool.<tool>.trustExitCode configuration variable did not apply
to built-in tools, but now it does.
Will merge to 'master'.
* jb/diff-no-index-no-abbrev (2016-12-08) 1 commit
(merged to 'next' on 2016-12-12 at 959981ef50)
+ diff: handle --no-abbrev in no-index case
"git diff --no-index" did not take "--no-abbrev" option.
Will merge to 'master'.
* vk/p4-submit-shelve (2016-11-29) 1 commit
(merged to 'next' on 2016-12-12 at 3fce6df117)
+ git-p4: allow submit to create shelved changelists.
(this branch is used by ld/p4-update-shelve.)
Will merge to 'master'.
* jk/http-walker-limit-redirect-2.9 (2016-12-06) 5 commits
(merged to 'next' on 2016-12-12 at 3e4bcd7bca)
+ http: treat http-alternates like redirects
+ http: make redirects more obvious
+ remote-curl: rename shadowed options variable
+ http: always update the base URL for redirects
+ http: simplify update_url_from_redirect
(this branch is used by jk/http-walker-limit-redirect.)
Transport with dumb http can be fooled into following foreign URLs
that the end user does not intend to, especially with the server
side redirects and http-alternates mechanism, which can lead to
security issues. Tighten the redirection and make it more obvious
to the end user when it happens.
Will merge to 'master'.
* jk/http-walker-limit-redirect (2016-12-06) 2 commits
(merged to 'next' on 2016-12-12 at 8b58025e3a)
+ http-walker: complain about non-404 loose object errors
+ Merge branch 'ew/http-walker' into jk/http-walker-limit-redirect
(this branch uses jk/http-walker-limit-redirect-2.9.)
Update the error messages from the dumb-http client when it fails
to obtain loose objects; we used to give sensible error message
only upon 404 but we now forbid unexpected redirects that needs to
be reported with something sensible.
Will merge to 'master'.
* ah/grammos (2016-12-05) 3 commits
(merged to 'next' on 2016-12-12 at 13ad487b28)
+ clone,fetch: explain the shallow-clone option a little more clearly
+ receive-pack: improve English grammar of denyCurrentBranch message
+ bisect: improve English grammar of not-ancestors message
A few messages have been fixed for their grammatical errors.
Will merge to 'master'.
* ak/commit-only-allow-empty (2016-12-09) 2 commits
(merged to 'next' on 2016-12-12 at 54188ab23c)
+ commit: remove 'Clever' message for --only --amend
+ commit: make --only --allow-empty work without paths
"git commit --allow-empty --only" (no pathspec) with dirty index
ought to be an acceptable way to create a new commit that does not
change any paths, but it was forbidden (perhaps because nobody
needed it).
Will merge to 'master'.
* bb/unicode-9.0 (2016-12-11) 6 commits
- update_unicode.sh: restore hexadecimal output
- update_unicode.sh: remove the plane filters
- update_unicode.sh: update the uniset repo if it exists
- unicode_width.h: update the tables to Unicode 9.0
- update_unicode.sh: strip the plane offsets from the double_width[] table
- update_unicode.sh: automatically download newer definition files
The character width table has been updated to match Unicode 9.0
Will merge to 'next'.
* ld/p4-update-shelve (2016-12-05) 1 commit
(merged to 'next' on 2016-12-12 at 22f6bec94c)
+ git-p4: support updating an existing shelved changelist
(this branch uses vk/p4-submit-shelve.)
Will merge to 'master'.
* ld/p4-worktree (2016-12-05) 1 commit
- git-p4: support secondary working trees managed by "git worktree"
Iffy.
cf. <20161202224319.5385-2-luke@diamand.org>
* ls/p4-empty-file-on-lfs (2016-12-05) 1 commit
(merged to 'next' on 2016-12-12 at 1fce8e037a)
+ git-p4: fix empty file processing for large file system backend GitLFS
"git p4" LFS support was broken when LFS stores an empty blob.
Will merge to 'master'.
* ls/p4-retry-thrice (2016-12-05) 1 commit
(merged to 'next' on 2016-12-12 at 9462e660a8)
+ git-p4: add config to retry p4 commands; retry 3 times by default
Will merge to 'master'.
* ls/t0021-fixup (2016-12-05) 1 commit
(merged to 'next' on 2016-12-12 at db652e691a)
+ t0021: minor filter process test cleanup
Will merge to 'master'.
* ls/travis-update-p4-and-lfs (2016-12-05) 1 commit
(merged to 'next' on 2016-12-12 at 5496caa048)
+ travis-ci: update P4 to 16.2 and GitLFS to 1.5.2 in Linux build
The default Travis-CI configuration specifies newer P4 and GitLFS.
Will merge to 'master'.
* sb/t3600-cleanup (2016-12-05) 1 commit
(merged to 'next' on 2016-12-12 at d9996af5e8)
+ t3600: remove useless redirect
Code cleanup.
Will merge to 'master'.
* sb/unpack-trees-grammofix (2016-12-05) 1 commit
(merged to 'next' on 2016-12-12 at 29e536f590)
+ unpack-trees: fix grammar for untracked files in directories
Will merge to 'master'.
* da/difftool-dir-diff-fix (2016-12-08) 1 commit
(merged to 'next' on 2016-12-12 at fd31a92ad6)
+ difftool: fix dir-diff index creation when in a subdirectory
"git difftool --dir-diff" had a minor regression when started from
a subdirectory, which has been fixed.
Will merge to 'master'.
* jk/stash-disable-renames-internally (2016-12-06) 1 commit
(merged to 'next' on 2016-12-12 at e2b97aae68)
+ stash: prefer plumbing over git-diff
When diff.renames configuration is on (and with Git 2.9 and later,
it is enabled by default, which made it worse), "git stash"
misbehaved if a file is removed and another file with a very
similar content is added.
Will merge to 'master'.
* jk/xdiff-drop-xdl-fast-hash (2016-12-06) 1 commit
- xdiff: drop XDL_FAST_HASH
Retire the "fast hash" that had disastrous performance issues in
some corner cases.
Will merge to 'next'.
* ls/filter-process (2016-12-06) 1 commit
(merged to 'next' on 2016-12-12 at 8ed1f9eb02)
+ docs: warn about possible '=' in clean/smudge filter process values
Doc update.
Will merge to 'master'.
* nd/for-each-ref-ignore-case (2016-12-05) 1 commit
(merged to 'next' on 2016-12-12 at 527cc4f275)
+ tag, branch, for-each-ref: add --ignore-case for sorting and filtering
"git branch --list" and friends learned "--ignore-case" option to
optionally sort branches and tags case insensitively.
Will merge to 'master'.
* rj/git-version-gen-do-not-force-abbrev (2016-12-06) 1 commit
(merged to 'next' on 2016-12-12 at e37970c3f5)
+ GIT-VERSION-GEN: do not force abbreviation length used by 'describe'
A minor build update.
Will merge to 'master'.
* jc/renormalize-merge-kill-safer-crlf (2016-12-01) 4 commits
(merged to 'next' on 2016-12-12 at 041b834f81)
+ convert: git cherry-pick -Xrenormalize did not work
+ Merge branch 'tb/t0027-raciness-fix' into jc/renormalize-merge-kill-safer-crlf
+ merge-recursive: handle NULL in add_cacheinfo() correctly
+ cherry-pick: demonstrate a segmentation fault
Fix a corner case in merge-recursive regression that crept in
during 2.10 development cycle.
Will merge to 'master'.
* js/difftool-builtin (2016-11-28) 2 commits
- difftool: implement the functionality in the builtin
- difftool: add a skeleton for the upcoming builtin
Rewrite a scripted porcelain "git difftool" in C.
Under discussion.
* nd/qsort-in-merge-recursive (2016-11-28) 1 commit
(merged to 'next' on 2016-12-12 at e9700f5b93)
+ merge-recursive.c: use string_list_sort instead of qsort
Code simplification.
Will merge to 'master'.
* bw/push-dry-run (2016-11-23) 2 commits
(merged to 'next' on 2016-12-12 at bde7a0f9ae)
+ push: fix --dry-run to not push submodules
+ push: --dry-run updates submodules when --recurse-submodules=on-demand
(this branch uses hv/submodule-not-yet-pushed-fix; is tangled with sb/push-make-submodule-check-the-default.)
"git push --dry-run --recurse-submodule=on-demand" wasn't
"--dry-run" in the submodules.
Will merge to 'master'.
* sb/push-make-submodule-check-the-default (2016-11-29) 2 commits
(merged to 'next' on 2016-12-12 at 1863e05af5)
+ push: change submodule default to check when submodules exist
+ submodule add: extend force flag to add existing repos
(this branch uses hv/submodule-not-yet-pushed-fix; is tangled with bw/push-dry-run.)
Turn the default of "push.recurseSubmodules" to "check" when
submodules seem to be in use.
Will merge to 'master'.
* jk/rev-parse-symbolic-parents-fix (2016-11-16) 1 commit
(merged to 'next' on 2016-12-12 at 6839c1ea28)
+ rev-parse: fix parent shorthands with --symbolic
"git rev-parse --symbolic" failed with a more recent notation like
"HEAD^-1" and "HEAD^!".
Will merge to 'master'.
* nd/worktree-list-fixup (2016-11-28) 5 commits
(merged to 'next' on 2016-12-12 at 1f46421a59)
+ worktree list: keep the list sorted
+ worktree.c: get_worktrees() takes a new flag argument
+ get_worktrees() must return main worktree as first item even on error
+ worktree: reorder an if statement
+ worktree.c: zero new 'struct worktree' on allocation
(this branch is used by nd/worktree-move and sb/submodule-embed-gitdir.)
The output from "git worktree list" was made in readdir() order,
and was unstable.
Will merge to 'master'.
* jk/trailers-placeholder-in-pretty (2016-12-11) 2 commits
(merged to 'next' on 2016-12-12 at 57de4e699a)
+ ref-filter: add support to display trailers as part of contents
+ pretty: add %(trailers) format for displaying trailers of a commit message
(this branch uses jt/use-trailer-api-in-commands.)
In addition to %(subject), %(body), "log --pretty=format:..."
learned a new placeholder %(trailers).
Will merge to 'master'.
* sb/submodule-embed-gitdir (2016-12-09) 6 commits
- submodule: add absorb-git-dir function
- move connect_work_tree_and_git_dir to dir.h
- worktree: have a function to check if worktrees are in use
- test-lib-functions.sh: teach test_commit -C <dir>
- submodule helper: support super prefix
- submodule: use absolute path for computing relative path connecting
(this branch uses nd/worktree-list-fixup; is tangled with nd/worktree-move.)
A new submodule helper "git submodule embedgitdirs" to make it
easier to move embedded .git/ directory for submodules in a
superproject to .git/modules/ (and point the latter with the former
that is turned into a "gitdir:" file) has been added.
Waiting for review to conclude.
cf. <20161208014623.7588-1-sbeller@google.com>
* dt/empty-submodule-in-merge (2016-11-17) 1 commit
(merged to 'next' on 2016-12-12 at 6de2350b2b)
+ submodules: allow empty working-tree dirs in merge/cherry-pick
An empty directory in a working tree that can simply be nuked used
to interfere while merging or cherry-picking a change to create a
submodule directory there, which has been fixed..
Will merge to 'master'.
* bw/grep-recurse-submodules (2016-11-22) 6 commits
- grep: search history of moved submodules
- grep: enable recurse-submodules to work on <tree> objects
- grep: optionally recurse into submodules
- grep: add submodules as a grep source type
- submodules: load gitmodules file from commit sha1
- submodules: add helper functions to determine presence of submodules
"git grep" learns to optionally recurse into submodules
Has anybody else seen t7814 being flakey with this series?
* dt/smart-http-detect-server-going-away (2016-11-18) 2 commits
(merged to 'next' on 2016-12-05 at 3ea70d01af)
+ upload-pack: optionally allow fetching any sha1
+ remote-curl: don't hang when a server dies before any output
Originally merged to 'next' on 2016-11-21
When the http server gives an incomplete response to a smart-http
rpc call, it could lead to client waiting for a full response that
will never come. Teach the client side to notice this condition
and abort the transfer.
An improvement counterproposal has failed.
cf. <20161114194049.mktpsvgdhex2f4zv@sigill.intra.peff.net>
Will cook in 'next'.
* mm/push-social-engineering-attack-doc (2016-11-14) 1 commit
(merged to 'next' on 2016-12-05 at 9a2b5bd1a9)
+ doc: mention transfer data leaks in more places
Originally merged to 'next' on 2016-11-16
Doc update on fetching and pushing.
Will cook in 'next'.
* jc/compression-config (2016-11-15) 1 commit
(merged to 'next' on 2016-12-05 at 323769ca07)
+ compression: unify pack.compression configuration parsing
Originally merged to 'next' on 2016-11-23
Compression setting for producing packfiles were spread across
three codepaths, one of which did not honor any configuration.
Unify these so that all of them honor core.compression and
pack.compression variables the same way.
Will cook in 'next'.
* mm/gc-safety-doc (2016-11-16) 1 commit
(merged to 'next' on 2016-12-05 at 031ecc1886)
+ git-gc.txt: expand discussion of races with other processes
Originally merged to 'next' on 2016-11-17
Doc update.
Will cook in 'next'.
* hv/submodule-not-yet-pushed-fix (2016-11-16) 4 commits
(merged to 'next' on 2016-12-05 at c9d729fca2)
+ submodule_needs_pushing(): explain the behaviour when we cannot answer
+ batch check whether submodule needs pushing into one call
+ serialize collection of refs that contain submodule changes
+ serialize collection of changed submodules
(this branch is used by bw/push-dry-run and sb/push-make-submodule-check-the-default.)
Originally merged to 'next' on 2016-11-21
The code in "git push" to compute if any commit being pushed in the
superproject binds a commit in a submodule that hasn't been pushed
out was overly inefficient, making it unusable even for a small
project that does not have any submodule but have a reasonable
number of refs.
Will cook in 'next'.
* kn/ref-filter-branch-list (2016-12-08) 20 commits
- branch: implement '--format' option
- branch: use ref-filter printing APIs
- branch, tag: use porcelain output
- ref-filter: allow porcelain to translate messages in the output
- ref-filter: add an 'rstrip=<N>' option to atoms which deal with refnames
- ref-filter: modify the 'lstrip=<N>' option to work with negative '<N>'
- ref-filter: rename the 'strip' option to 'lstrip'
- ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal()
- ref-filter: introduce refname_atom_parser()
- ref-filter: introduce refname_atom_parser_internal()
- ref-filter: make "%(symref)" atom work with the ':short' modifier
- ref-filter: add support for %(upstream:track,nobracket)
- ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreams
- ref-filter: introduce format_ref_array_item()
- ref-filter: move get_head_description() from branch.c
- ref-filter: modify "%(objectname:short)" to take length
- ref-filter: implement %(if:equals=<string>) and %(if:notequals=<string>)
- ref-filter: include reference to 'used_atom' within 'atom_value'
- ref-filter: implement %(if), %(then), and %(else) atoms
- for-each-ref: do not segv with %(HEAD) on an unborn branch
The code to list branches in "git branch" has been consolidated
with the more generic ref-filter API.
Rerolled, reviewed, looking good.
* bw/transport-protocol-policy (2016-12-05) 5 commits
- transport: add from_user parameter to is_transport_allowed
- http: create function to get curl allowed protocols
- http: always warn if libcurl version is too old
- transport: add protocol policy config option
- lib-proto-disable: variable name fix
Finer-grained control of what protocols are allowed for transports
during clone/fetch/push have been enabled via a new configuration
mechanism.
* jt/fetch-no-redundant-tag-fetch-map (2016-11-11) 1 commit
(merged to 'next' on 2016-12-05 at 432f9469a7)
+ fetch: do not redundantly calculate tag refmap
Originally merged to 'next' on 2016-11-16
Code cleanup to avoid using redundant refspecs while fetching with
the --tags option.
Will cook in 'next'.
* sb/submodule-config-cleanup (2016-11-22) 3 commits
(merged to 'next' on 2016-12-05 at 658b8764bf)
+ submodule-config: clarify parsing of null_sha1 element
+ submodule-config: rename commit_sha1 to treeish_name
+ submodule config: inline config_from_{name, path}
Originally merged to 'next' on 2016-11-23
Minor code clean-up.
Will cook in 'next'.
* jc/push-default-explicit (2016-10-31) 2 commits
(merged to 'next' on 2016-12-05 at d63f3777af)
+ push: test pushing ambiguously named branches
+ push: do not use potentially ambiguous default refspec
Originally merged to 'next' on 2016-11-01
A lazy "git push" without refspec did not internally use a fully
specified refspec to perform 'current', 'simple', or 'upstream'
push, causing unnecessary "ambiguous ref" errors.
Will cook in 'next'.
* jt/use-trailer-api-in-commands (2016-11-29) 5 commits
(merged to 'next' on 2016-12-12 at da1f140ad4)
+ sequencer: use trailer's trailer layout
+ trailer: have function to describe trailer layout
+ trailer: avoid unnecessary splitting on lines
+ commit: make ignore_non_trailer take buf/len
+ trailer: be stricter in parsing separators
(this branch is used by jk/trailers-placeholder-in-pretty.)
Commands that operate on a log message and add lines to the trailer
blocks, such as "format-patch -s", "cherry-pick (-x|-s)", and
"commit -s", have been taught to use the logic of and share the
code with "git interpret-trailer".
Will merge to 'master'.
* nd/rebase-forget (2016-12-11) 1 commit
(merged to 'next' on 2016-12-12 at 50b5d28af4)
+ rebase: add --quit to cleanup rebase, leave everything else untouched
"git rebase" learned "--forget" option, which allows a user to
remove the metadata left by an earlier "git rebase" that was
manually aborted without using "git rebase --abort".
Will merge to 'master'.
* jc/git-open-cloexec (2016-11-02) 3 commits
- sha1_file: stop opening files with O_NOATIME
- git_open_cloexec(): use fcntl(2) w/ FD_CLOEXEC fallback
- git_open(): untangle possible NOATIME and CLOEXEC interactions
The codeflow of setting NOATIME and CLOEXEC on file descriptors Git
opens has been simplified.
We may want to drop the tip one.
* jk/no-looking-at-dotgit-outside-repo-final (2016-10-26) 1 commit
(merged to 'next' on 2016-12-05 at 0c77e39cd5)
+ setup_git_env: avoid blind fall-back to ".git"
Originally merged to 'next' on 2016-10-26
This is the endgame of the topic to avoid blindly falling back to
".git" when the setup sequence said we are _not_ in Git repository.
A corner case that happens to work right now may be broken by a
call to die("BUG").
Will cook in 'next'.
* jc/reset-unmerge (2016-10-24) 1 commit
- reset: --unmerge
After "git add" is run prematurely during a conflict resolution,
"git diff" can no longer be used as a way to sanity check by
looking at the combined diff. "git reset" learned a new
"--unmerge" option to recover from this situation.
Will discard.
This may not be needed, given that update-index has a similar
option.
* jc/merge-base-fp-only (2016-10-19) 8 commits
. merge-base: fp experiment
- merge: allow to use only the fp-only merge bases
- merge-base: limit the output to bases that are on first-parent chain
- merge-base: mark bases that are on first-parent chain
- merge-base: expose get_merge_bases_many_0() a bit more
- merge-base: stop moving commits around in remove_redundant()
- sha1_name: remove ONELINE_SEEN bit
- commit: simplify fastpath of merge-base
An experiment of merge-base that ignores common ancestors that are
not on the first parent chain.
Will discard.
The whole premise feels wrong.
* tb/convert-stream-check (2016-10-27) 2 commits
- convert.c: stream and fast search for binary
- read-cache: factor out get_sha1_from_index() helper
End-of-line conversion sometimes needs to see if the current blob
in the index has NULs and CRs to base its decision. We used to
always get a full statistics over the blob, but in many cases we
can return early when we have seen "enough" (e.g. if we see a
single NUL, the blob will be handled as binary). The codepaths
have been optimized by using streaming interface.
Will discard.
Retracted.
cf. <20161102071646.GA5094@tb-raspi>
* pb/bisect (2016-10-18) 27 commits
- bisect--helper: remove the dequote in bisect_start()
- bisect--helper: retire `--bisect-auto-next` subcommand
- bisect--helper: retire `--bisect-autostart` subcommand
- bisect--helper: retire `--bisect-write` subcommand
- bisect--helper: `bisect_replay` shell function in C
- bisect--helper: `bisect_log` shell function in C
- bisect--helper: retire `--write-terms` subcommand
- bisect--helper: retire `--check-expected-revs` subcommand
- bisect--helper: `bisect_state` & `bisect_head` shell function in C
- bisect--helper: `bisect_autostart` shell function in C
- bisect--helper: retire `--next-all` subcommand
- bisect--helper: retire `--bisect-clean-state` subcommand
- bisect--helper: `bisect_next` and `bisect_auto_next` shell function in C
- t6030: no cleanup with bad merge base
- bisect--helper: `bisect_start` shell function partially in C
- bisect--helper: `get_terms` & `bisect_terms` shell function in C
- bisect--helper: `bisect_next_check` & bisect_voc shell function in C
- bisect--helper: `check_and_set_terms` shell function in C
- bisect--helper: `bisect_write` shell function in C
- bisect--helper: `is_expected_rev` & `check_expected_revs` shell function in C
- bisect--helper: `bisect_reset` shell function in C
- wrapper: move is_empty_file() and rename it as is_empty_or_missing_file()
- t6030: explicitly test for bisection cleanup
- bisect--helper: `bisect_clean_state` shell function in C
- bisect--helper: `write_terms` shell function in C
- bisect: rewrite `check_term_format` shell function in C
- bisect--helper: use OPT_CMDMODE instead of OPT_BOOL
Move more parts of "git bisect" to C.
Waiting for review.
* st/verify-tag (2016-10-10) 7 commits
- t/t7004-tag: Add --format specifier tests
- t/t7030-verify-tag: Add --format specifier tests
- builtin/tag: add --format argument for tag -v
- builtin/verify-tag: add --format to verify-tag
- tag: add format specifier to gpg_verify_tag
- ref-filter: add function to print single ref_array_item
- gpg-interface, tag: add GPG_VERIFY_QUIET flag
"git tag" and "git verify-tag" learned to put GPG verification
status in their "--format=<placeholders>" output format.
Waiting for a reroll.
cf. <20161007210721.20437-1-santiago@nyu.edu>
* sb/attr (2016-11-11) 35 commits
- completion: clone can initialize specific submodules
- clone: add --init-submodule=<pathspec> switch
- submodule update: add `--init-default-path` switch
- pathspec: allow escaped query values
- pathspec: allow querying for attributes
- pathspec: move prefix check out of the inner loop
- pathspec: move long magic parsing out of prefix_pathspec
- Documentation: fix a typo
- attr: keep attr stack for each check
- attr: convert to new threadsafe API
- attr: make git_check_attr_counted static
- attr.c: outline the future plans by heavily commenting
- attr.c: always pass check[] to collect_some_attrs()
- attr.c: introduce empty_attr_check_elems()
- attr.c: correct ugly hack for git_all_attrs()
- attr.c: rename a local variable check
- attr.c: pass struct git_attr_check down the callchain
- attr.c: add push_stack() helper
- attr: support quoting pathname patterns in C style
- attr: expose validity check for attribute names
- attr: add counted string version of git_check_attr()
- attr: retire git_check_attrs() API
- attr: convert git_check_attrs() callers to use the new API
- attr: convert git_all_attrs() to use "struct git_attr_check"
- attr: (re)introduce git_check_attr() and struct git_attr_check
- attr: rename function and struct related to checking attributes
- attr.c: plug small leak in parse_attr_line()
- attr.c: tighten constness around "git_attr" structure
- attr.c: simplify macroexpand_one()
- attr.c: mark where #if DEBUG ends more clearly
- attr.c: complete a sentence in a comment
- attr.c: explain the lack of attr-name syntax check in parse_attr()
- attr.c: update a stale comment on "struct match_attr"
- attr.c: use strchrnul() to scan for one line
- commit.c: use strchrnul() to scan for one line
The attributes API has been updated so that it can later be
optimized using the knowledge of which attributes are queried.
Building on top of the updated API, the pathspec machinery learned
to select only paths with given attributes set.
Waiting for review.
* va/i18n-perl-scripts (2016-11-11) 16 commits
- i18n: difftool: mark warnings for translation
- i18n: send-email: mark composing message for translation
- i18n: send-email: mark string with interpolation for translation
- i18n: send-email: mark warnings and errors for translation
- i18n: send-email: mark strings for translation
- i18n: add--interactive: mark status words for translation
- i18n: add--interactive: remove %patch_modes entries
- i18n: add--interactive: mark edit_hunk_manually message for translation
- i18n: add--interactive: i18n of help_patch_cmd
- i18n: add--interactive: mark patch prompt for translation
- i18n: add--interactive: mark plural strings
- i18n: clean.c: match string with git-add--interactive.perl
- i18n: add--interactive: mark strings with interpolation for translation
- i18n: add--interactive: mark simple here-documents for translation
- i18n: add--interactive: mark strings for translation
- Git.pm: add subroutines for commenting lines
Porcelain scripts written in Perl are getting internationalized.
Waiting for review.
* jc/latin-1 (2016-09-26) 2 commits
(merged to 'next' on 2016-12-05 at fb549caa12)
+ utf8: accept "latin-1" as ISO-8859-1
+ utf8: refactor code to decide fallback encoding
Originally merged to 'next' on 2016-09-28
Some platforms no longer understand "latin-1" that is still seen in
the wild in e-mail headers; replace them with "iso-8859-1" that is
more widely known when conversion fails from/to it.
Will cook in 'next'.
* sg/fix-versioncmp-with-common-suffix (2016-12-08) 8 commits
- versioncmp: generalize version sort suffix reordering
- squash! versioncmp: use earliest-longest contained suffix to determine sorting order
- versioncmp: use earliest-longest contained suffix to determine sorting order
- versioncmp: cope with common part overlapping with prerelease suffix
- versioncmp: pass full tagnames to swap_prereleases()
- t7004-tag: add version sort tests to show prerelease reordering issues
- t7004-tag: use test_config helper
- t7004-tag: delete unnecessary tags with test_when_finished
The prereleaseSuffix feature of version comparison that is used in
"git tag -l" did not correctly when two or more prereleases for the
same release were present (e.g. when 2.0, 2.0-beta1, and 2.0-beta2
are there and the code needs to compare 2.0-beta1 and 2.0-beta2).
Waiting for review.
cf. <20161208142401.1329-1-szeder.dev@gmail.com>
* jc/pull-rebase-ff (2016-11-29) 1 commit
- pull: fast-forward "pull --rebase=true"
"git pull --rebase", when there is no new commits on our side since
we forked from the upstream, should be able to fast-forward without
invoking "git rebase", but it didn't.
* jc/merge-drop-old-syntax (2015-04-29) 1 commit
(merged to 'next' on 2016-12-05 at 041946dae0)
+ merge: drop 'git merge <message> HEAD <commit>' syntax
Originally merged to 'next' on 2016-10-11
Stop supporting "git merge <message> HEAD <commit>" syntax that has
been deprecated since October 2007, and issues a deprecation
warning message since v2.5.0.
Will cook in 'next'.
^ permalink raw reply
* Re: [PATCH v2] difftool: fix dir-diff index creation when in a subdirectory
From: Junio C Hamano @ 2016-12-12 21:35 UTC (permalink / raw)
To: David Aguilar; +Cc: Git ML, Frank Becker, Johannes Schindelin, John Keeping
In-Reply-To: <20161207101608.16058-1-davvid@gmail.com>
Thanks; queued and pushed out together with the follow-up series.
^ permalink raw reply
* Re: [PATCH v3 1/4] real_path: resolve symlinks by hand
From: Junio C Hamano @ 2016-12-12 22:19 UTC (permalink / raw)
To: Brandon Williams
Cc: git, sbeller, peff, jacob.keller, ramsay, tboegi, j6t, pclouds
In-Reply-To: <1481566615-75299-2-git-send-email-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
> +/* removes the last path component from 'path' except if 'path' is root */
> +static void strip_last_component(struct strbuf *path)
> +{
> + size_t offset = offset_1st_component(path->buf);
> + size_t len = path->len;
> +
> + /* Find start of the last component */
> + while (offset < len && !is_dir_sep(path->buf[len - 1]))
> + len--;
If somebody at a higher level in the callchain has already
normalized path, this is not a problem, but this will behave
"unexpectedly" when path ends with a dir_sep byte (or more).
E.g. for input path "foo/bar/", the above loop runs zero times and
then ...
> + /* Skip sequences of multiple path-separators */
> + while (offset < len && is_dir_sep(path->buf[len - 1]))
> + len--;
... the slash at the end is removed, leaving "foo/bar" in path.
> + strbuf_setlen(path, len);
> +}
> ...
> +/* get (and remove) the next component in 'remaining' and place it in 'next' */
> +static void get_next_component(struct strbuf *next, struct strbuf *remaining)
> +{
> + char *start = NULL;
> + char *end = NULL;
> +
> + strbuf_reset(next);
> +
> + /* look for the next component */
> + /* Skip sequences of multiple path-separators */
> + for (start = remaining->buf; is_dir_sep(*start); start++)
> + ; /* nothing */
> + /* Find end of the path component */
> + for (end = start; *end && !is_dir_sep(*end); end++)
> + ; /* nothing */
> +
> + strbuf_add(next, start, end - start);
> + /* remove the component from 'remaining' */
> + strbuf_remove(remaining, 0, end - remaining->buf);
> +}
Unlike the strip_last_component(), I think this one is more
carefully done and avoids getting fooled by //extra//slashes// at
the beginning or at the end, which does help in the correctness of
the loop we see below.
> @@ -58,74 +88,112 @@ static const char *real_path_internal(const char *path, int die_on_error)
> goto error_out;
> }
>
> + strbuf_reset(&resolved);
> +
> + if (is_absolute_path(path)) {
> + /* absolute path; start with only root as being resolved */
> + int offset = offset_1st_component(path);
> + strbuf_add(&resolved, path, offset);
> + strbuf_addstr(&remaining, path + offset);
> + } else {
> + /* relative path; can use CWD as the initial resolved path */
> + if (strbuf_getcwd(&resolved)) {
> + if (die_on_error)
> + die_errno("unable to get current working directory");
> + else
> + goto error_out;
> }
> + strbuf_addstr(&remaining, path);
> + }
>
> + /* Iterate over the remaining path components */
> + while (remaining.len > 0) {
> + get_next_component(&next, &remaining);
> +
> + if (next.len == 0) {
> + continue; /* empty component */
> + } else if (next.len == 1 && !strcmp(next.buf, ".")) {
> + continue; /* '.' component */
> + } else if (next.len == 2 && !strcmp(next.buf, "..")) {
> + /* '..' component; strip the last path component */
> + strip_last_component(&resolved);
Wouldn't this let "resolved" eventually run out of the path
components to strip for a malformed input e.g. "/a/../../b"?
> + ...
> + /*
> + * if there are still remaining components to resolve
> + * then append them to symlink
> + */
> + if (remaining.len) {
> + strbuf_addch(&symlink, '/');
This can add duplicate dir_sep if readlink(2)'ed contents of the
symbolic link already ends with a slash, but I think it (together
with the fact that the code does nothing to normalize what is read
from the symbolic link) probably does not matter, given the way how
get_next_component() is implemented.
> + strbuf_addbuf(&symlink, &remaining);
> + }
> +
> + /*
> + * use the symlink as the remaining components that
> + * need to be resloved
> + */
> + strbuf_swap(&symlink, &remaining);
> + }
> }
>
> + retval = resolved.buf;
> +
> error_out:
> + strbuf_release(&remaining);
> + strbuf_release(&next);
> + strbuf_release(&symlink);
>
> return retval;
> }
^ permalink raw reply
* Re: [PATCH v3 2/4] real_path: convert real_path_internal to strbuf_realpath
From: Junio C Hamano @ 2016-12-12 22:20 UTC (permalink / raw)
To: Brandon Williams
Cc: git, sbeller, peff, jacob.keller, ramsay, tboegi, j6t, pclouds
In-Reply-To: <1481566615-75299-3-git-send-email-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
> Change the name of real_path_internal to strbuf_realpath. In addition
> push the static strbuf up to its callers and instead take as a
> parameter a pointer to a strbuf to use for the final result.
>
> This change makes strbuf_realpath reentrant.
Yup, this step makes sense.
^ permalink raw reply
* Re: [PATCH v3 3/4] real_path: create real_pathdup
From: Junio C Hamano @ 2016-12-12 22:25 UTC (permalink / raw)
To: Brandon Williams
Cc: git, sbeller, peff, jacob.keller, ramsay, tboegi, j6t, pclouds
In-Reply-To: <1481566615-75299-4-git-send-email-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
> Create real_pathdup which returns a caller owned string of the resolved
> realpath based on the provide path.
>
> Signed-off-by: Brandon Williams <bmwill@google.com>
> ---
> abspath.c | 13 +++++++++++++
> cache.h | 1 +
> 2 files changed, 14 insertions(+)
>
> diff --git a/abspath.c b/abspath.c
> index 8c6c76b..79ee310 100644
> --- a/abspath.c
> +++ b/abspath.c
> @@ -205,6 +205,19 @@ const char *real_path_if_valid(const char *path)
> return strbuf_realpath(&realpath, path, 0);
> }
>
> +char *real_pathdup(const char *path)
> +{
> + struct strbuf realpath = STRBUF_INIT;
> + char *retval = NULL;
> +
> + if (strbuf_realpath(&realpath, path, 0))
> + retval = strbuf_detach(&realpath, NULL);
> +
> + strbuf_release(&realpath);
> +
> + return retval;
> +}
OK. Taken alone, the above makes a reader wonder if it still makes
sense for strbuf_realpath() to return realpath.buf (or NULL upon
error). An obvious alternative is to return 0 on success and -1 on
failure.
But other callers of strbuf_realpath() are mimicking the historical
"give a path in 'const char *', receive a path in 'const char *'
that you have to xstrdup() if you want to keep it" interface, and
this interface may be easier for them. I dunno.
> /*
> * Use this to get an absolute path from a relative one. If you want
> * to resolve links, you should use real_path.
> diff --git a/cache.h b/cache.h
> index 7a81294..e12a5d9 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -1068,6 +1068,7 @@ char *strbuf_realpath(struct strbuf *resolved, const char *path,
> int die_on_error);
> const char *real_path(const char *path);
> const char *real_path_if_valid(const char *path);
> +char *real_pathdup(const char *path);
> const char *absolute_path(const char *path);
> const char *remove_leading_path(const char *in, const char *prefix);
> const char *relative_path(const char *in, const char *prefix, struct strbuf *sb);
^ permalink raw reply
* Re: [PATCH v3 4/4] real_path: have callers use real_pathdup and strbuf_realpath
From: Junio C Hamano @ 2016-12-12 22:26 UTC (permalink / raw)
To: Brandon Williams
Cc: git, sbeller, peff, jacob.keller, ramsay, tboegi, j6t, pclouds
In-Reply-To: <1481566615-75299-5-git-send-email-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
> Migrate callers of real_path() who duplicate the retern value to use
> real_pathdup or strbuf_realpath.
Looks good.
^ permalink raw reply
* Re: [PATCH 0/2] handling alternates paths with colons
From: Junio C Hamano @ 2016-12-12 22:37 UTC (permalink / raw)
To: Jeff King; +Cc: Johannes Sixt, Klaus Ethgen, git
In-Reply-To: <20161212194929.bdcihf7orjabzb2h@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> So here are patches that do that. It kicks in only when the first
> character of a path is a double-quote, and then expects the usual
> C-style quoting.
The quote being per delimited component is what makes this fifth
approach a huge win.
All sane components on a list-valued environment are still honored
and an insane component that has either a colon in the middle or
begins with a double-quote gets quoted. As long as nobody used a
path that begins with a double-quote as an element in such a
list-valued environment (and they cannot be, as using a non-absolute
path as an element does not make much sense), this will be safe, and
a path with a colon didn't work with Git unaware of the new quoting
rule anyway. Nice.
^ permalink raw reply
* Re: [RFC PATCH] send-email: allow a custom hook to prevent sending email
From: Junio C Hamano @ 2016-12-12 22:38 UTC (permalink / raw)
To: Stefan Beller; +Cc: Jeff King, Brandon Williams, git@vger.kernel.org
In-Reply-To: <CAGZ79kZVjsJjreKJgnOH1T-k-zfpfqivxw1gGm_dx4GU4tte2Q@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
> $ git send-email 00* --cc=list --cc=bmwill --cc=duy --to=jch
> 0000-cover-letter.patch
> ...
> (mbox) Adding cc: Stefan Beller <sbeller@google.com> from line 'From:
> Stefan Beller <sbeller@google.com>'
>
> From: Stefan Beller <sbeller@google.com>
> To: gitster@pobox.com
> Cc: git@vger.kernel.org,
> bmwill@google.com,
> pclouds@gmail.com,
> Stefan Beller <sbeller@google.com>
> Subject: [PATCHv7 0/6] submodule absorbgitdirs
> Date: Mon, 12 Dec 2016 11:04:29 -0800
> Message-Id: <20161212190435.10358-1-sbeller@google.com>
> X-Mailer: git-send-email 2.11.0.rc2.49.ge1f3b0c.dirty
>
> Send this email? ([y]es|[n]o|[q]uit|[a]ll):
>
> ---
> This is usually where I just say "a" and carry on with life.
> The hook would ideally reformat the last lines to be
> ---
> X-Mailer: git-send-email 2.11.0.rc2.49.ge1f3b0c.dirty
> send-email hook thinks it is a bad idea to send out this series:
> <output of hook, e.g.
> referencing a typo in patch 5.
> or a mismatch of patch version numbers>
>
> Send this email? ([y]es|[n]o|[q]uit|[a]ll):
> ---
Yup, sounds sensible (the "... thinks it is a bad idea ..." line may
probably not be needed; the hook can say why it is unhappy itself).
Thanks.
^ permalink raw reply
* Re: [PATCH v3 1/4] real_path: resolve symlinks by hand
From: Brandon Williams @ 2016-12-12 22:50 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, sbeller, peff, jacob.keller, ramsay, tboegi, j6t, pclouds
In-Reply-To: <xmqqd1gw94f1.fsf@gitster.mtv.corp.google.com>
On 12/12, Junio C Hamano wrote:
> Brandon Williams <bmwill@google.com> writes:
>
> > +/* removes the last path component from 'path' except if 'path' is root */
> > +static void strip_last_component(struct strbuf *path)
> > +{
> > + size_t offset = offset_1st_component(path->buf);
> > + size_t len = path->len;
> > +
> > + /* Find start of the last component */
> > + while (offset < len && !is_dir_sep(path->buf[len - 1]))
> > + len--;
>
> If somebody at a higher level in the callchain has already
> normalized path, this is not a problem, but this will behave
> "unexpectedly" when path ends with a dir_sep byte (or more).
>
> E.g. for input path "foo/bar/", the above loop runs zero times and
> then ...
>
> > + /* Skip sequences of multiple path-separators */
> > + while (offset < len && is_dir_sep(path->buf[len - 1]))
> > + len--;
>
> ... the slash at the end is removed, leaving "foo/bar" in path.
>
The way this is currently used I don't believe this scenario can happen
(since input to this shouldn't have trailing slashes), but if others
begin to use this function then yes, that is an implicit assumption. I
think it may be an ok assumption though since this is only called on
"resolved" which is the ouput and needs to be normalized to begin with. To
fix this we could simply add the while loop that strips dir_sep at the
beginning as well as at the end, like so:
/* Skip sequences of multiple path-separators */
while (offset < len && is_dir_sep(path->buf[len - 1]))
len--;
/* Skip sequences of multiple path-separators */
while (offset < len && !is_dir_sep(path->buf[len - 1]))
len--;
/* Skip sequences of multiple path-separators */
while (offset < len && is_dir_sep(path->buf[len - 1]))
len--;
> > + strbuf_setlen(path, len);
> > +}
> > ...
> > +/* get (and remove) the next component in 'remaining' and place it in 'next' */
> > +static void get_next_component(struct strbuf *next, struct strbuf *remaining)
> > +{
> > + char *start = NULL;
> > + char *end = NULL;
> > +
> > + strbuf_reset(next);
> > +
> > + /* look for the next component */
> > + /* Skip sequences of multiple path-separators */
> > + for (start = remaining->buf; is_dir_sep(*start); start++)
> > + ; /* nothing */
> > + /* Find end of the path component */
> > + for (end = start; *end && !is_dir_sep(*end); end++)
> > + ; /* nothing */
> > +
> > + strbuf_add(next, start, end - start);
> > + /* remove the component from 'remaining' */
> > + strbuf_remove(remaining, 0, end - remaining->buf);
> > +}
>
> Unlike the strip_last_component(), I think this one is more
> carefully done and avoids getting fooled by //extra//slashes// at
> the beginning or at the end, which does help in the correctness of
> the loop we see below.
>
> > @@ -58,74 +88,112 @@ static const char *real_path_internal(const char *path, int die_on_error)
> > goto error_out;
> > }
> >
> > + strbuf_reset(&resolved);
> > +
> > + if (is_absolute_path(path)) {
> > + /* absolute path; start with only root as being resolved */
> > + int offset = offset_1st_component(path);
> > + strbuf_add(&resolved, path, offset);
> > + strbuf_addstr(&remaining, path + offset);
> > + } else {
> > + /* relative path; can use CWD as the initial resolved path */
> > + if (strbuf_getcwd(&resolved)) {
> > + if (die_on_error)
> > + die_errno("unable to get current working directory");
> > + else
> > + goto error_out;
> > }
> > + strbuf_addstr(&remaining, path);
> > + }
> >
> > + /* Iterate over the remaining path components */
> > + while (remaining.len > 0) {
> > + get_next_component(&next, &remaining);
> > +
> > + if (next.len == 0) {
> > + continue; /* empty component */
> > + } else if (next.len == 1 && !strcmp(next.buf, ".")) {
> > + continue; /* '.' component */
> > + } else if (next.len == 2 && !strcmp(next.buf, "..")) {
> > + /* '..' component; strip the last path component */
> > + strip_last_component(&resolved);
>
> Wouldn't this let "resolved" eventually run out of the path
> components to strip for a malformed input e.g. "/a/../../b"?
>
As I understand it, that path is correct and would resolve to "/b". The
strip_last_component function doesn't allow striping the "1st" component
or the "root" component. So if resolved is "/" and we encounter a ".."
which requires striping of the last component, the result would be "/".
> > + ...
> > + /*
> > + * if there are still remaining components to resolve
> > + * then append them to symlink
> > + */
> > + if (remaining.len) {
> > + strbuf_addch(&symlink, '/');
>
> This can add duplicate dir_sep if readlink(2)'ed contents of the
> symbolic link already ends with a slash, but I think it (together
> with the fact that the code does nothing to normalize what is read
> from the symbolic link) probably does not matter, given the way how
> get_next_component() is implemented.
>
Yes, I think the way get_next_component() is written will account for
non-normalized symlink contents. This way we only have to worry about
normalizing input in one location (maybe two with
strip_last_component()).
> > + strbuf_addbuf(&symlink, &remaining);
> > + }
> > +
> > + /*
> > + * use the symlink as the remaining components that
> > + * need to be resloved
> > + */
> > + strbuf_swap(&symlink, &remaining);
> > + }
> > }
> >
> > + retval = resolved.buf;
> > +
> > error_out:
> > + strbuf_release(&remaining);
> > + strbuf_release(&next);
> > + strbuf_release(&symlink);
> >
> > return retval;
> > }
>
--
Brandon Williams
^ permalink raw reply
* Re: [PATCH v3 1/4] real_path: resolve symlinks by hand
From: Junio C Hamano @ 2016-12-12 23:32 UTC (permalink / raw)
To: Brandon Williams
Cc: git, sbeller, peff, jacob.keller, ramsay, tboegi, j6t, pclouds
In-Reply-To: <20161212225006.GB193413@google.com>
Brandon Williams <bmwill@google.com> writes:
> On 12/12, Junio C Hamano wrote:
> ...
>> E.g. for input path "foo/bar/", the above loop runs zero times and
>> then ...
>>
>> > + /* Skip sequences of multiple path-separators */
>> > + while (offset < len && is_dir_sep(path->buf[len - 1]))
>> > + len--;
>>
>> ... the slash at the end is removed, leaving "foo/bar" in path.
>
> The way this is currently used I don't believe this scenario can happen
> (since input to this shouldn't have trailing slashes), but if others
> begin to use this function then yes, that is an implicit assumption.
OK.
>> > + /* Iterate over the remaining path components */
>> > + while (remaining.len > 0) {
>> > + get_next_component(&next, &remaining);
>> > +
>> > + if (next.len == 0) {
>> > + continue; /* empty component */
>> > + } else if (next.len == 1 && !strcmp(next.buf, ".")) {
>> > + continue; /* '.' component */
>> > + } else if (next.len == 2 && !strcmp(next.buf, "..")) {
>> > + /* '..' component; strip the last path component */
>> > + strip_last_component(&resolved);
>>
>> Wouldn't this let "resolved" eventually run out of the path
>> components to strip for a malformed input e.g. "/a/../../b"?
>
> As I understand it, that path is correct and would resolve to "/b".
That is OK on the traditional UNIX end.
I am not sure if we want to handle the "//host/share/$remaining" in
this codepath, though. If we do, then this is still an issue (IIRC,
somebody explained that we do not want to step into //host/share/
part when seeing ".."---we'd at least need to leave a NEEDSWORK
comment so that interested parties can later take a look into it.
^ permalink raw reply
* Re: [PATCH v3 4/4] real_path: have callers use real_pathdup and strbuf_realpath
From: Junio C Hamano @ 2016-12-12 23:47 UTC (permalink / raw)
To: Brandon Williams
Cc: git, sbeller, peff, jacob.keller, ramsay, tboegi, j6t, pclouds
In-Reply-To: <xmqqzik07pin.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
> Brandon Williams <bmwill@google.com> writes:
>
>> Migrate callers of real_path() who duplicate the retern value to use
>> real_pathdup or strbuf_realpath.
>
> Looks good.
This has small non-textual conflicts with Stefan's embed^Wabsorption
topic; please holler if you spot my mismerge. Thanks.
^ permalink raw reply
* Re: [PATCH 1/3] update_unicode.sh: update the uniset repo if it exists
From: Beat Bolli @ 2016-12-12 23:50 UTC (permalink / raw)
To: git; +Cc: Torsten Bögershausen
In-Reply-To: <xmqqr35dm203.fsf@gitster.mtv.corp.google.com>
On 12.12.16 19:33, Junio C Hamano wrote:
> Torsten Bögershausen <tboegi@web.de> writes:
>
>> If I run ./update_unicode.sh on the latest master of
>> https://github.com/depp/uniset.git , commit
>> a5fac4a091857dd5429cc2d, I get a diff in unicode_width.h like
>> this:
>>
>> -{ 0x0300, 0x036F },
>>
>> +{ 768, 879 },
>>
>> IOW, all hex values are printed as decimal values.
>> Not a problem for the compiler, but for the human
>> to check the unicode tables.
>>
>> So I think we should "pin" the version of uniset.
>
> Sure, and I'd rather see the update-unicode.sh script moved
> somewhere in contrib/ while at it. Those who are interested in
> keeping up with the unicode standard are tiny minority of the
> developer population, and most of us would treat the built width
> table as the source (after all, that is what we ship).
>
> To be bluntly honest, I'd rather not to see "update-unicode.sh"
> download and build uniset at all. It's as if po/ hierarchy shipping
> with its own script to download and build msgmerge--that's madness.
> Needless to say, shipping the sources for uniset embedded in our
> project tree (either as a snapshot-fork or as a submodule) is even
> worse. Those who want to muck with po/ are expected to have
> msgmerge and friends. Why not expect the same for those who want to
> update the unicode width table?
>
> I'd rather see a written instruction telling which snapshot to get
> and from where to build and place on their $PATH in the README file,
> sitting next to the update-unicode.sh script in contrib/uniwidth/
> directory, for those who are interested in building the width table
> "from the source", and the update-unicode.sh script to assume that
> uniset is available.
>
OK. So please don't merge bb/unicode-9.0 to next yet; I'll prepare a
reroll following your description.
Torsten, is this alright with you?
Cheers, Beat
^ permalink raw reply
* [PATCH] t3600: slightly modernize style
From: Stefan Beller @ 2016-12-12 23:54 UTC (permalink / raw)
To: gitster; +Cc: git, Stefan Beller
Remove the space between redirection and file name.
Also remove unnecessary invocations of subshells, such as
(cd submod &&
echo X >untracked
) &&
as there is no point of having the shell for functional purposes.
In case of a single Git command use the `-C` option to let Git cd into
the directory.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
t/t3600-rm.sh | 122 ++++++++++++++++++++++++----------------------------------
1 file changed, 50 insertions(+), 72 deletions(-)
I came across this test script while developing the checkout series.
This motivated me to modernize the style while reading it.
The removal of spawning subshells for just one command could be argued to be
a performance gain as well, though I did not measure it.
Thanks,
Stefan
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 14f0edca2b..5e5a16c863 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -111,21 +111,21 @@ test_expect_success 'Remove nonexistent file with --ignore-unmatch' '
'
test_expect_success '"rm" command printed' '
- echo frotz > test-file &&
+ echo frotz >test-file &&
git add test-file &&
git commit -m "add file for rm test" &&
- git rm test-file > rm-output &&
+ git rm test-file >rm-output &&
test $(grep "^rm " rm-output | wc -l) = 1 &&
rm -f test-file rm-output &&
git commit -m "remove file from rm test"
'
test_expect_success '"rm" command suppressed with --quiet' '
- echo frotz > test-file &&
+ echo frotz >test-file &&
git add test-file &&
git commit -m "add file for rm --quiet test" &&
- git rm --quiet test-file > rm-output &&
- test $(wc -l < rm-output) = 0 &&
+ git rm --quiet test-file >rm-output &&
+ test_must_be_empty rm-output &&
rm -f test-file rm-output &&
git commit -m "remove file from rm --quiet test"
'
@@ -221,7 +221,7 @@ test_expect_success 'Call "rm" from outside the work tree' '
mkdir repo &&
(cd repo &&
git init &&
- echo something > somefile &&
+ echo something >somefile &&
git add somefile &&
git commit -m "add a file" &&
(cd .. &&
@@ -287,7 +287,7 @@ test_expect_success 'rm removes empty submodules from work tree' '
git commit -m "add submodule" &&
git rm submod &&
test ! -e submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -298,7 +298,7 @@ test_expect_success 'rm removes removed submodule from index and .gitmodules' '
git submodule update &&
rm -rf submod &&
git rm submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -309,7 +309,7 @@ test_expect_success 'rm removes work tree of unmodified submodules' '
git submodule update &&
git rm submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -320,7 +320,7 @@ test_expect_success 'rm removes a submodule with a trailing /' '
git submodule update &&
git rm submod/ &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -335,17 +335,15 @@ test_expect_success 'rm succeeds when given a directory with a trailing /' '
test_expect_success 'rm of a populated submodule with different HEAD fails unless forced' '
git reset --hard &&
git submodule update &&
- (cd submod &&
- git checkout HEAD^
- ) &&
+ git -C submod checkout HEAD^ &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -418,34 +416,30 @@ test_expect_success 'rm issues a warning when section is not found in .gitmodule
test_expect_success 'rm of a populated submodule with modifications fails unless forced' '
git reset --hard &&
git submodule update &&
- (cd submod &&
- echo X >empty
- ) &&
+ echo X >submod/empty &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
test_expect_success 'rm of a populated submodule with untracked files fails unless forced' '
git reset --hard &&
git submodule update &&
- (cd submod &&
- echo X >untracked
- ) &&
+ echo X >submod/untracked &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -461,16 +455,12 @@ test_expect_success 'setup submodule conflict' '
git add nitfol &&
git commit -m "added nitfol 2" &&
git checkout -b conflict1 master &&
- (cd submod &&
- git fetch &&
- git checkout branch1
- ) &&
+ git -C submod fetch &&
+ git -C submod checkout branch1 &&
git add submod &&
git commit -m "submod 1" &&
git checkout -b conflict2 master &&
- (cd submod &&
- git checkout branch2
- ) &&
+ git -C submod checkout branch2 &&
git add submod &&
git commit -m "submod 2"
'
@@ -486,7 +476,7 @@ test_expect_success 'rm removes work tree of unmodified conflicted submodule' '
test_must_fail git merge conflict2 &&
git rm submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -494,18 +484,16 @@ test_expect_success 'rm of a conflicted populated submodule with different HEAD
git checkout conflict1 &&
git reset --hard &&
git submodule update &&
- (cd submod &&
- git checkout HEAD^
- ) &&
+ git -C submod checkout HEAD^ &&
test_must_fail git merge conflict2 &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -515,18 +503,16 @@ test_expect_success 'rm of a conflicted populated submodule with modifications f
git checkout conflict1 &&
git reset --hard &&
git submodule update &&
- (cd submod &&
- echo X >empty
- ) &&
+ echo X >submod/empty &&
test_must_fail git merge conflict2 &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -536,18 +522,16 @@ test_expect_success 'rm of a conflicted populated submodule with untracked files
git checkout conflict1 &&
git reset --hard &&
git submodule update &&
- (cd submod &&
- echo X >untracked
- ) &&
+ echo X >submod/untracked &&
test_must_fail git merge conflict2 &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -564,12 +548,12 @@ test_expect_success 'rm of a conflicted populated submodule with a .git director
test_must_fail git rm submod &&
test -d submod &&
test -d submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
test_must_fail git rm -f submod &&
test -d submod &&
test -d submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git merge --abort &&
rm -rf submod
@@ -581,7 +565,7 @@ test_expect_success 'rm of a conflicted unpopulated submodule succeeds' '
test_must_fail git merge conflict2 &&
git rm submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -597,12 +581,12 @@ test_expect_success 'rm of a populated submodule with a .git directory fails eve
test_must_fail git rm submod &&
test -d submod &&
test -d submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
! test -s actual &&
test_must_fail git rm -f submod &&
test -d submod &&
test -d submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
! test -s actual &&
rm -rf submod
'
@@ -629,58 +613,52 @@ test_expect_success 'setup subsubmodule' '
test_expect_success 'rm recursively removes work tree of unmodified submodules' '
git rm submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
test_expect_success 'rm of a populated nested submodule with different nested HEAD fails unless forced' '
git reset --hard &&
git submodule update --recursive &&
- (cd submod/subsubmod &&
- git checkout HEAD^
- ) &&
+ git -C submod/subsubmod checkout HEAD^ &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
test_expect_success 'rm of a populated nested submodule with nested modifications fails unless forced' '
git reset --hard &&
git submodule update --recursive &&
- (cd submod/subsubmod &&
- echo X >empty
- ) &&
+ echo X >submod/subsubmod/empty &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
test_expect_success 'rm of a populated nested submodule with nested untracked files fails unless forced' '
git reset --hard &&
git submodule update --recursive &&
- (cd submod/subsubmod &&
- echo X >untracked
- ) &&
+ echo X >submod/subsubmod/untracked &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -695,12 +673,12 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
test_must_fail git rm submod &&
test -d submod &&
test -d submod/subsubmod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
! test -s actual &&
test_must_fail git rm -f submod &&
test -d submod &&
test -d submod/subsubmod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
! test -s actual &&
rm -rf submod
'
@@ -716,7 +694,7 @@ test_expect_success 'checking out a commit after submodule removal needs manual
echo "?? submod/" >expected &&
test_cmp expected actual &&
rm -rf submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
! test -s actual
'
--
2.11.0.rc2.55.g1345a36.dirty
^ permalink raw reply related
* Re: [PATCH v3 4/4] real_path: have callers use real_pathdup and strbuf_realpath
From: Stefan Beller @ 2016-12-12 23:58 UTC (permalink / raw)
To: Junio C Hamano
Cc: Brandon Williams, git@vger.kernel.org, Jeff King, Jacob Keller,
Ramsay Jones, Torsten Bögershausen, Johannes Sixt,
Duy Nguyen
In-Reply-To: <xmqqfuls7lri.fsf@gitster.mtv.corp.google.com>
On Mon, Dec 12, 2016 at 3:47 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Brandon Williams <bmwill@google.com> writes:
>>
>>> Migrate callers of real_path() who duplicate the retern value to use
>>> real_pathdup or strbuf_realpath.
>>
>> Looks good.
>
> This has small non-textual conflicts with Stefan's embed^Wabsorption
> topic; please holler if you spot my mismerge. Thanks.
>
5f6a003727 (Merge branch 'bw/realpath-wo-chdir' into jch)
looks good to me.
^ permalink raw reply
* Re: [PATCHv2 5/7] versioncmp: cope with common part overlapping with prerelease suffix
From: SZEDER Gábor @ 2016-12-13 0:27 UTC (permalink / raw)
To: Junio C Hamano
Cc: Jeff King, Nguyễn Thái Ngọc Duy, Leho Kraav, git
In-Reply-To: <xmqqshps96ti.fsf@gitster.mtv.corp.google.com>
On Mon, Dec 12, 2016 at 10:27 PM, Junio C Hamano <gitster@pobox.com> wrote:
> SZEDER Gábor <szeder.dev@gmail.com> writes:
>
>> diff --git a/versioncmp.c b/versioncmp.c
>> index a55c23ad5..f86ac562e 100644
>> --- a/versioncmp.c
>> +++ b/versioncmp.c
>> @@ -26,12 +26,15 @@ static int initialized;
>>
>> /*
>> * off is the offset of the first different character in the two strings
>> - * s1 and s2. If either s1 or s2 contains a prerelease suffix starting
>> - * at that offset, it will be forced to be on top.
>> + * s1 and s2. If either s1 or s2 contains a prerelease suffix containing
>> + * that offset, then that string will be forced to be on top.
>> *
>> - * If both s1 and s2 contain a (different) suffix at that position,
>> + * If both s1 and s2 contain a (different) suffix around that position,
>> * their order is determined by the order of those two suffixes in the
>> * configuration.
>> + * If any of the strings contains more than one different suffixes around
>> + * that position, then that string is sorted according to the contained
>> + * suffix which comes first in the configuration.
>> *
>> * Return non-zero if *diff contains the return value for versioncmp()
>> */
>> @@ -44,10 +47,21 @@ static int swap_prereleases(const char *s1,
>>
>> for (i = 0; i < prereleases->nr; i++) {
>> const char *suffix = prereleases->items[i].string;
>> - if (i1 == -1 && starts_with(s1 + off, suffix))
>> - i1 = i;
>> - if (i2 == -1 && starts_with(s2 + off, suffix))
>> - i2 = i;
>> + int j, start, suffix_len = strlen(suffix);
>> + if (suffix_len < off)
>> + start = off - suffix_len + 1;
>> + else
>> + start = 0;
>
> Now that this function has to rewind the beginning of the comparison
> earlier than the given 'off', it makes me wonder if it still makes
> sense for the caller to compute it in the first place.
The caller has to compute it anyway, because it must deal with all the
cases when the two compared tagnames are not reordered based on their
(prerelease)suffix.
^ permalink raw reply
* Re: [PATCH v3 4/4] real_path: have callers use real_pathdup and strbuf_realpath
From: Brandon Williams @ 2016-12-13 1:15 UTC (permalink / raw)
To: Stefan Beller
Cc: Junio C Hamano, git@vger.kernel.org, Jeff King, Jacob Keller,
Ramsay Jones, Torsten Bögershausen, Johannes Sixt,
Duy Nguyen
In-Reply-To: <CAGZ79kbYAyGwTb7AkymoaMo+TPGVRiv8kn00fXGS=S_ZVFG0Jw@mail.gmail.com>
On 12/12, Stefan Beller wrote:
> On Mon, Dec 12, 2016 at 3:47 PM, Junio C Hamano <gitster@pobox.com> wrote:
> > Junio C Hamano <gitster@pobox.com> writes:
> >
> >> Brandon Williams <bmwill@google.com> writes:
> >>
> >>> Migrate callers of real_path() who duplicate the retern value to use
> >>> real_pathdup or strbuf_realpath.
> >>
> >> Looks good.
> >
> > This has small non-textual conflicts with Stefan's embed^Wabsorption
> > topic; please holler if you spot my mismerge. Thanks.
> >
>
> 5f6a003727 (Merge branch 'bw/realpath-wo-chdir' into jch)
> looks good to me.
Looks good to me as well.
--
Brandon Williams
^ permalink raw reply
* [PATCH 0/6] git-rm absorbs submodule git directory before deletion
From: Stefan Beller @ 2016-12-13 1:40 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, Stefan Beller
The "checkout --recurse-submodules" series got too large to comfortably send
it out for review, so I had to break it up into smaller series'; this is the
first subseries, but it makes sense on its own.
This series teaches git-rm to absorb the git directory of a submodule instead
of failing and complaining about the git directory preventing deletion.
It applies on origin/sb/submodule-embed-gitdir.
Any feedback welcome!
Thanks,
Stefan
Stefan Beller (6):
submodule.h: add extern keyword to functions
submodule: modernize ok_to_remove_submodule to use argv_array
submodule: add flags to ok_to_remove_submodule
ok_to_remove_submodule: absorb the submodule git dir
t3600: slightly modernize style
rm: add absorb a submodules git dir before deletion
builtin/rm.c | 21 +++-----
cache.h | 2 +
entry.c | 5 ++
submodule.c | 77 +++++++++++++++++++++++-----
submodule.h | 64 ++++++++++++++---------
t/t3600-rm.sh | 159 +++++++++++++++++++++++----------------------------------
6 files changed, 182 insertions(+), 146 deletions(-)
--
2.11.0.rc2.35.g7af3268
^ permalink raw reply
* [PATCH 2/6] submodule: modernize ok_to_remove_submodule to use argv_array
From: Stefan Beller @ 2016-12-13 1:40 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, Stefan Beller
In-Reply-To: <20161213014055.14268-1-sbeller@google.com>
Instead of constructing the NULL terminated array ourselves, we
should make use of the argv_array infrastructure.
While at it, adapt the error messages to reflect the actual invocation.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
submodule.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/submodule.c b/submodule.c
index 45ccfb7ab4..9f0b544ebe 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1023,13 +1023,6 @@ int ok_to_remove_submodule(const char *path)
{
ssize_t len;
struct child_process cp = CHILD_PROCESS_INIT;
- const char *argv[] = {
- "status",
- "--porcelain",
- "-u",
- "--ignore-submodules=none",
- NULL,
- };
struct strbuf buf = STRBUF_INIT;
int ok_to_remove = 1;
@@ -1039,14 +1032,15 @@ int ok_to_remove_submodule(const char *path)
if (!submodule_uses_gitfile(path))
return 0;
- cp.argv = argv;
+ argv_array_pushl(&cp.args, "status", "--porcelain", "-u",
+ "--ignore-submodules=none", NULL);
prepare_submodule_repo_env(&cp.env_array);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.out = -1;
cp.dir = path;
if (start_command(&cp))
- die("Could not run 'git status --porcelain -uall --ignore-submodules=none' in submodule %s", path);
+ die(_("could not run 'git status --porcelain -u --ignore-submodules=none' in submodule %s"), path);
len = strbuf_read(&buf, cp.out, 1024);
if (len > 2)
@@ -1054,7 +1048,7 @@ int ok_to_remove_submodule(const char *path)
close(cp.out);
if (finish_command(&cp))
- die("'git status --porcelain -uall --ignore-submodules=none' failed in submodule %s", path);
+ die(_("'git status --porcelain -u --ignore-submodules=none' failed in submodule %s"), path);
strbuf_release(&buf);
return ok_to_remove;
--
2.11.0.rc2.35.g7af3268
^ permalink raw reply related
* [PATCH 4/6] ok_to_remove_submodule: absorb the submodule git dir
From: Stefan Beller @ 2016-12-13 1:40 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, Stefan Beller
In-Reply-To: <20161213014055.14268-1-sbeller@google.com>
When deciding if a submodule can be deleted a major
reason to say no is the git directory of the submodule
being contained in the submodules working directory.
Instead of failing migrate the git directory into the
superproject and proceed with the other checks.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
submodule.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/submodule.c b/submodule.c
index 2d13744b06..e42efa2337 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1026,11 +1026,22 @@ int ok_to_remove_submodule(const char *path, unsigned flags)
struct strbuf buf = STRBUF_INIT;
int ok_to_remove = 1;
+ /* Is it there? */
if (!file_exists(path) || is_empty_dir(path))
return 1;
- if (!submodule_uses_gitfile(path))
- return 0;
+ /* Does it have a .git directory? */
+ if (!submodule_uses_gitfile(path)) {
+ absorb_git_dir_into_superproject("", path,
+ ABSORB_GITDIR_RECURSE_SUBMODULES);
+
+ /*
+ * We should be using a gitfile by now. Let's double
+ * check as losing the git dir would be fatal.
+ */
+ if (!submodule_uses_gitfile(path))
+ return 0;
+ }
argv_array_pushl(&cp.args, "status", "--porcelain",
"--ignore-submodules=none", NULL);
--
2.11.0.rc2.35.g7af3268
^ permalink raw reply related
* [PATCH 1/6] submodule.h: add extern keyword to functions
From: Stefan Beller @ 2016-12-13 1:40 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, Stefan Beller
In-Reply-To: <20161213014055.14268-1-sbeller@google.com>
As the upcoming series will add a lot of functions to the submodule
header, let's first make the header consistent to the rest of the project
by adding the extern keyword to functions.
As per the CodingGuidelines we try to stay below 80 characters per line,
so adapt all those functions to stay below 80 characters that are already
using more than one line. Those function using just one line are better
kept in one line than breaking them up into multiple lines just for the
goal of staying below the character limit as it makes grepping
for functions easier if they are one liners.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
submodule.h | 55 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 30 insertions(+), 25 deletions(-)
diff --git a/submodule.h b/submodule.h
index 6229054b99..61fb610749 100644
--- a/submodule.h
+++ b/submodule.h
@@ -29,50 +29,55 @@ struct submodule_update_strategy {
};
#define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED, NULL}
-int is_staging_gitmodules_ok(void);
-int update_path_in_gitmodules(const char *oldpath, const char *newpath);
-int remove_path_from_gitmodules(const char *path);
-void stage_updated_gitmodules(void);
-void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
+extern int is_staging_gitmodules_ok(void);
+extern int update_path_in_gitmodules(const char *oldpath, const char *newpath);
+extern int remove_path_from_gitmodules(const char *path);
+extern void stage_updated_gitmodules(void);
+extern void set_diffopt_flags_from_submodule_config(struct diff_options *,
const char *path);
-int submodule_config(const char *var, const char *value, void *cb);
-void gitmodules_config(void);
-int parse_submodule_update_strategy(const char *value,
+extern int submodule_config(const char *var, const char *value, void *cb);
+extern void gitmodules_config(void);
+extern int parse_submodule_update_strategy(const char *value,
struct submodule_update_strategy *dst);
-const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);
-void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
-void show_submodule_summary(FILE *f, const char *path,
+extern const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);
+extern void handle_ignore_submodules_arg(struct diff_options *, const char *);
+extern void show_submodule_summary(FILE *f, const char *path,
const char *line_prefix,
struct object_id *one, struct object_id *two,
unsigned dirty_submodule, const char *meta,
const char *del, const char *add, const char *reset);
-void show_submodule_inline_diff(FILE *f, const char *path,
+extern void show_submodule_inline_diff(FILE *f, const char *path,
const char *line_prefix,
struct object_id *one, struct object_id *two,
unsigned dirty_submodule, const char *meta,
const char *del, const char *add, const char *reset,
const struct diff_options *opt);
-void set_config_fetch_recurse_submodules(int value);
-void check_for_new_submodule_commits(unsigned char new_sha1[20]);
-int fetch_populated_submodules(const struct argv_array *options,
+extern void set_config_fetch_recurse_submodules(int value);
+extern void check_for_new_submodule_commits(unsigned char new_sha1[20]);
+extern int fetch_populated_submodules(const struct argv_array *options,
const char *prefix, int command_line_option,
int quiet, int max_parallel_jobs);
-unsigned is_submodule_modified(const char *path, int ignore_untracked);
-int submodule_uses_gitfile(const char *path);
-int ok_to_remove_submodule(const char *path);
-int merge_submodule(unsigned char result[20], const char *path, const unsigned char base[20],
- const unsigned char a[20], const unsigned char b[20], int search);
-int find_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name,
- struct string_list *needs_pushing);
-int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name);
-int parallel_submodules(void);
+extern unsigned is_submodule_modified(const char *path, int ignore_untracked);
+extern int submodule_uses_gitfile(const char *path);
+extern int ok_to_remove_submodule(const char *path);
+extern int merge_submodule(unsigned char result[20], const char *path,
+ const unsigned char base[20],
+ const unsigned char a[20],
+ const unsigned char b[20], int search);
+extern int find_unpushed_submodules(unsigned char new_sha1[20],
+ const char *remotes_name,
+ struct string_list *needs_pushing);
+extern int push_unpushed_submodules(unsigned char new_sha1[20],
+ const char *remotes_name);
+extern void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
+extern int parallel_submodules(void);
/*
* Prepare the "env_array" parameter of a "struct child_process" for executing
* a submodule by clearing any repo-specific envirionment variables, but
* retaining any config in the environment.
*/
-void prepare_submodule_repo_env(struct argv_array *out);
+extern void prepare_submodule_repo_env(struct argv_array *out);
#define ABSORB_GITDIR_RECURSE_SUBMODULES (1<<0)
extern void absorb_git_dir_into_superproject(const char *prefix,
--
2.11.0.rc2.35.g7af3268
^ permalink raw reply related
* [PATCH 3/6] submodule: add flags to ok_to_remove_submodule
From: Stefan Beller @ 2016-12-13 1:40 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, Stefan Beller
In-Reply-To: <20161213014055.14268-1-sbeller@google.com>
In different contexts the question whether deleting a submodule is ok
to remove may be answered differently.
In 293ab15eea (submodule: teach rm to remove submodules unless they
contain a git directory, 2012-09-26) a case was made that we can safely
ignore ignored untracked files for removal as we explicitely ask for the
removal of the submodule.
In a later patch we want to remove submodules even when the user doesn't
explicitly ask for it (e.g. checking out a tree-ish in which the submodule
doesn't exist). In that case we want to be more careful when it comes
to deletion of untracked files. As of this patch it is unclear how this
will be implemented exactly, so we'll offer flags in which the caller
can specify how the different untracked files ought to be handled.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
builtin/rm.c | 3 ++-
submodule.c | 23 +++++++++++++++++++----
submodule.h | 5 ++++-
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/builtin/rm.c b/builtin/rm.c
index 3f3e24eb36..fdd7183f61 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -187,7 +187,8 @@ static int check_local_mod(struct object_id *head, int index_only)
*/
if (ce_match_stat(ce, &st, 0) ||
(S_ISGITLINK(ce->ce_mode) &&
- !ok_to_remove_submodule(ce->name)))
+ !ok_to_remove_submodule(ce->name,
+ SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED)))
local_changes = 1;
/*
diff --git a/submodule.c b/submodule.c
index 9f0b544ebe..2d13744b06 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1019,7 +1019,7 @@ int submodule_uses_gitfile(const char *path)
return 1;
}
-int ok_to_remove_submodule(const char *path)
+int ok_to_remove_submodule(const char *path, unsigned flags)
{
ssize_t len;
struct child_process cp = CHILD_PROCESS_INIT;
@@ -1032,15 +1032,27 @@ int ok_to_remove_submodule(const char *path)
if (!submodule_uses_gitfile(path))
return 0;
- argv_array_pushl(&cp.args, "status", "--porcelain", "-u",
+ argv_array_pushl(&cp.args, "status", "--porcelain",
"--ignore-submodules=none", NULL);
+
+ if (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED)
+ argv_array_push(&cp.args, "-uno");
+ else
+ argv_array_push(&cp.args, "-uall");
+
+ if (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED))
+ argv_array_push(&cp.args, "--ignored");
+
prepare_submodule_repo_env(&cp.env_array);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.out = -1;
cp.dir = path;
if (start_command(&cp))
- die(_("could not run 'git status --porcelain -u --ignore-submodules=none' in submodule %s"), path);
+ die(_("could not run 'git status --porcelain --ignore-submodules=none %s %s' in submodule '%s'"),
+ (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED) ? "-uno" : "-uall",
+ (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED)) ? "--ignored" : "",
+ path);
len = strbuf_read(&buf, cp.out, 1024);
if (len > 2)
@@ -1048,7 +1060,10 @@ int ok_to_remove_submodule(const char *path)
close(cp.out);
if (finish_command(&cp))
- die(_("'git status --porcelain -u --ignore-submodules=none' failed in submodule %s"), path);
+ die(_("'git status --porcelain --ignore-submodules=none %s %s' failed in submodule '%s'"),
+ (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED) ? "-uno" : "-uall",
+ (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED)) ? "--ignored" : "",
+ path);
strbuf_release(&buf);
return ok_to_remove;
diff --git a/submodule.h b/submodule.h
index 61fb610749..3ed3aa479a 100644
--- a/submodule.h
+++ b/submodule.h
@@ -59,7 +59,10 @@ extern int fetch_populated_submodules(const struct argv_array *options,
int quiet, int max_parallel_jobs);
extern unsigned is_submodule_modified(const char *path, int ignore_untracked);
extern int submodule_uses_gitfile(const char *path);
-extern int ok_to_remove_submodule(const char *path);
+
+#define SUBMODULE_REMOVAL_IGNORE_UNTRACKED (1<<0)
+#define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<1)
+extern int ok_to_remove_submodule(const char *path, unsigned flags);
extern int merge_submodule(unsigned char result[20], const char *path,
const unsigned char base[20],
const unsigned char a[20],
--
2.11.0.rc2.35.g7af3268
^ permalink raw reply related
* [PATCH 6/6] rm: add absorb a submodules git dir before deletion
From: Stefan Beller @ 2016-12-13 1:40 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, Stefan Beller
In-Reply-To: <20161213014055.14268-1-sbeller@google.com>
When deleting a submodule we need to keep the actual git directory around,
such that we do not lose local changes in there and at a later checkout
of the submodule we don't need to clone it again.
Implement `depopulate_submodule`, that migrates the git directory before
deletion of a submodule and afterwards the equivalent of "rm -rf", which
is already found in entry.c, so expose that and for clarity add a suffix
"_or_dir" to it.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
builtin/rm.c | 18 ++++++------------
cache.h | 2 ++
entry.c | 5 +++++
submodule.c | 31 +++++++++++++++++++++++++++++++
submodule.h | 6 ++++++
t/t3600-rm.sh | 41 ++++++++++++++++-------------------------
6 files changed, 66 insertions(+), 37 deletions(-)
diff --git a/builtin/rm.c b/builtin/rm.c
index fdd7183f61..f8c5e9b6c6 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -400,18 +400,12 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
continue;
}
} else {
- strbuf_reset(&buf);
- strbuf_addstr(&buf, path);
- if (!remove_dir_recursively(&buf, 0)) {
- removed = 1;
- if (!remove_path_from_gitmodules(path))
- gitmodules_modified = 1;
- strbuf_release(&buf);
- continue;
- } else if (!file_exists(path))
- /* Submodule was removed by user */
- if (!remove_path_from_gitmodules(path))
- gitmodules_modified = 1;
+ if (file_exists(path))
+ depopulate_submodule(path);
+ removed = 1;
+ if (!remove_path_from_gitmodules(path))
+ gitmodules_modified = 1;
+ continue;
/* Fallthrough and let remove_path() fail. */
}
}
diff --git a/cache.h b/cache.h
index a50a61a197..b645ca2f9a 100644
--- a/cache.h
+++ b/cache.h
@@ -2018,4 +2018,6 @@ void sleep_millisec(int millisec);
*/
void safe_create_dir(const char *dir, int share);
+extern void remove_directory_or_die(struct strbuf *path);
+
#endif /* CACHE_H */
diff --git a/entry.c b/entry.c
index c6eea240b6..02c4ac9f22 100644
--- a/entry.c
+++ b/entry.c
@@ -73,6 +73,11 @@ static void remove_subtree(struct strbuf *path)
die_errno("cannot rmdir '%s'", path->buf);
}
+void remove_directory_or_die(struct strbuf *path)
+{
+ remove_subtree(path);
+}
+
static int create_file(const char *path, unsigned int mode)
{
mode = (mode & 0100) ? 0777 : 0666;
diff --git a/submodule.c b/submodule.c
index e42efa2337..3770ecb7b9 100644
--- a/submodule.c
+++ b/submodule.c
@@ -308,6 +308,37 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
strbuf_release(&sb);
}
+void depopulate_submodule(const char *path)
+{
+ struct strbuf pathbuf = STRBUF_INIT;
+ char *dot_git = xstrfmt("%s/.git", path);
+
+ /* Is it populated? */
+ if (!resolve_gitdir(dot_git))
+ goto out;
+
+ /* Does it have a .git directory? */
+ if (!submodule_uses_gitfile(path)) {
+ absorb_git_dir_into_superproject("", path,
+ ABSORB_GITDIR_RECURSE_SUBMODULES);
+
+ if (!submodule_uses_gitfile(path)) {
+ /*
+ * We should be using a gitfile by now. Let's double
+ * check as losing the git dir would be fatal.
+ */
+ die("BUG: could not absorb git directory for '%s'", path);
+ }
+ }
+
+ strbuf_addstr(&pathbuf, path);
+ remove_directory_or_die(&pathbuf);
+
+out:
+ strbuf_release(&pathbuf);
+ free(dot_git);
+}
+
/* Helper function to display the submodule header line prior to the full
* summary output. If it can locate the submodule objects directory it will
* attempt to lookup both the left and right commits and put them into the
diff --git a/submodule.h b/submodule.h
index 3ed3aa479a..516e377a12 100644
--- a/submodule.h
+++ b/submodule.h
@@ -53,6 +53,12 @@ extern void show_submodule_inline_diff(FILE *f, const char *path,
const char *del, const char *add, const char *reset,
const struct diff_options *opt);
extern void set_config_fetch_recurse_submodules(int value);
+
+/*
+ * Removes a submodule from a given path. When the submodule contains its
+ * git directory instead of a gitlink, migrate that first into the superproject.
+ */
+extern void depopulate_submodule(const char *path);
extern void check_for_new_submodule_commits(unsigned char new_sha1[20]);
extern int fetch_populated_submodules(const struct argv_array *options,
const char *prefix, int command_line_option,
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 5e5a16c863..5aa6db584c 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -569,26 +569,22 @@ test_expect_success 'rm of a conflicted unpopulated submodule succeeds' '
test_cmp expect actual
'
-test_expect_success 'rm of a populated submodule with a .git directory fails even when forced' '
+test_expect_success 'rm of a populated submodule with a .git directory migrates git dir' '
git checkout -f master &&
git reset --hard &&
git submodule update &&
(cd submod &&
rm .git &&
cp -R ../.git/modules/sub .git &&
- GIT_WORK_TREE=. git config --unset core.worktree
+ GIT_WORK_TREE=. git config --unset core.worktree &&
+ rm -r ../.git/modules/sub
) &&
- test_must_fail git rm submod &&
- test -d submod &&
- test -d submod/.git &&
- git status -s -uno --ignore-submodules=none >actual &&
- ! test -s actual &&
- test_must_fail git rm -f submod &&
- test -d submod &&
- test -d submod/.git &&
+ git rm submod 2>output.err &&
+ ! test -d submod &&
+ ! test -d submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
- ! test -s actual &&
- rm -rf submod
+ test -s actual &&
+ test_i18ngrep Migrating output.err
'
cat >expect.deepmodified <<EOF
@@ -667,27 +663,22 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
git submodule update --recursive &&
(cd submod/subsubmod &&
rm .git &&
- cp -R ../../.git/modules/sub/modules/sub .git &&
+ mv ../../.git/modules/sub/modules/sub .git &&
GIT_WORK_TREE=. git config --unset core.worktree
) &&
- test_must_fail git rm submod &&
- test -d submod &&
- test -d submod/subsubmod/.git &&
- git status -s -uno --ignore-submodules=none >actual &&
- ! test -s actual &&
- test_must_fail git rm -f submod &&
- test -d submod &&
- test -d submod/subsubmod/.git &&
+ git rm submod 2>output.err &&
+ ! test -d submod &&
+ ! test -d submod/subsubmod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
- ! test -s actual &&
- rm -rf submod
+ test -s actual &&
+ test_i18ngrep Migrating output.err
'
test_expect_success 'checking out a commit after submodule removal needs manual updates' '
- git commit -m "submodule removal" submod &&
+ git commit -m "submodule removal" submod .gitmodules &&
git checkout HEAD^ &&
git submodule update &&
- git checkout -q HEAD^ 2>actual &&
+ git checkout -q HEAD^ &&
git checkout -q master 2>actual &&
test_i18ngrep "^warning: unable to rmdir submod:" actual &&
git status -s submod >actual &&
--
2.11.0.rc2.35.g7af3268
^ permalink raw reply related
* [PATCH 5/6] t3600: slightly modernize style
From: Stefan Beller @ 2016-12-13 1:40 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, Stefan Beller
In-Reply-To: <20161213014055.14268-1-sbeller@google.com>
Remove the space between redirection and file name.
Also remove unnecessary invocations of subshells, such as
(cd submod &&
echo X >untracked
) &&
as there is no point of having the shell for functional purposes.
In case of a single Git command use the `-C` option to let Git cd into
the directory.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
t/t3600-rm.sh | 122 ++++++++++++++++++++++++----------------------------------
1 file changed, 50 insertions(+), 72 deletions(-)
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 14f0edca2b..5e5a16c863 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -111,21 +111,21 @@ test_expect_success 'Remove nonexistent file with --ignore-unmatch' '
'
test_expect_success '"rm" command printed' '
- echo frotz > test-file &&
+ echo frotz >test-file &&
git add test-file &&
git commit -m "add file for rm test" &&
- git rm test-file > rm-output &&
+ git rm test-file >rm-output &&
test $(grep "^rm " rm-output | wc -l) = 1 &&
rm -f test-file rm-output &&
git commit -m "remove file from rm test"
'
test_expect_success '"rm" command suppressed with --quiet' '
- echo frotz > test-file &&
+ echo frotz >test-file &&
git add test-file &&
git commit -m "add file for rm --quiet test" &&
- git rm --quiet test-file > rm-output &&
- test $(wc -l < rm-output) = 0 &&
+ git rm --quiet test-file >rm-output &&
+ test_must_be_empty rm-output &&
rm -f test-file rm-output &&
git commit -m "remove file from rm --quiet test"
'
@@ -221,7 +221,7 @@ test_expect_success 'Call "rm" from outside the work tree' '
mkdir repo &&
(cd repo &&
git init &&
- echo something > somefile &&
+ echo something >somefile &&
git add somefile &&
git commit -m "add a file" &&
(cd .. &&
@@ -287,7 +287,7 @@ test_expect_success 'rm removes empty submodules from work tree' '
git commit -m "add submodule" &&
git rm submod &&
test ! -e submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -298,7 +298,7 @@ test_expect_success 'rm removes removed submodule from index and .gitmodules' '
git submodule update &&
rm -rf submod &&
git rm submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -309,7 +309,7 @@ test_expect_success 'rm removes work tree of unmodified submodules' '
git submodule update &&
git rm submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -320,7 +320,7 @@ test_expect_success 'rm removes a submodule with a trailing /' '
git submodule update &&
git rm submod/ &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -335,17 +335,15 @@ test_expect_success 'rm succeeds when given a directory with a trailing /' '
test_expect_success 'rm of a populated submodule with different HEAD fails unless forced' '
git reset --hard &&
git submodule update &&
- (cd submod &&
- git checkout HEAD^
- ) &&
+ git -C submod checkout HEAD^ &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -418,34 +416,30 @@ test_expect_success 'rm issues a warning when section is not found in .gitmodule
test_expect_success 'rm of a populated submodule with modifications fails unless forced' '
git reset --hard &&
git submodule update &&
- (cd submod &&
- echo X >empty
- ) &&
+ echo X >submod/empty &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
test_expect_success 'rm of a populated submodule with untracked files fails unless forced' '
git reset --hard &&
git submodule update &&
- (cd submod &&
- echo X >untracked
- ) &&
+ echo X >submod/untracked &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -461,16 +455,12 @@ test_expect_success 'setup submodule conflict' '
git add nitfol &&
git commit -m "added nitfol 2" &&
git checkout -b conflict1 master &&
- (cd submod &&
- git fetch &&
- git checkout branch1
- ) &&
+ git -C submod fetch &&
+ git -C submod checkout branch1 &&
git add submod &&
git commit -m "submod 1" &&
git checkout -b conflict2 master &&
- (cd submod &&
- git checkout branch2
- ) &&
+ git -C submod checkout branch2 &&
git add submod &&
git commit -m "submod 2"
'
@@ -486,7 +476,7 @@ test_expect_success 'rm removes work tree of unmodified conflicted submodule' '
test_must_fail git merge conflict2 &&
git rm submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -494,18 +484,16 @@ test_expect_success 'rm of a conflicted populated submodule with different HEAD
git checkout conflict1 &&
git reset --hard &&
git submodule update &&
- (cd submod &&
- git checkout HEAD^
- ) &&
+ git -C submod checkout HEAD^ &&
test_must_fail git merge conflict2 &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -515,18 +503,16 @@ test_expect_success 'rm of a conflicted populated submodule with modifications f
git checkout conflict1 &&
git reset --hard &&
git submodule update &&
- (cd submod &&
- echo X >empty
- ) &&
+ echo X >submod/empty &&
test_must_fail git merge conflict2 &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual &&
test_must_fail git config -f .gitmodules submodule.sub.url &&
test_must_fail git config -f .gitmodules submodule.sub.path
@@ -536,18 +522,16 @@ test_expect_success 'rm of a conflicted populated submodule with untracked files
git checkout conflict1 &&
git reset --hard &&
git submodule update &&
- (cd submod &&
- echo X >untracked
- ) &&
+ echo X >submod/untracked &&
test_must_fail git merge conflict2 &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -564,12 +548,12 @@ test_expect_success 'rm of a conflicted populated submodule with a .git director
test_must_fail git rm submod &&
test -d submod &&
test -d submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
test_must_fail git rm -f submod &&
test -d submod &&
test -d submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.conflict actual &&
git merge --abort &&
rm -rf submod
@@ -581,7 +565,7 @@ test_expect_success 'rm of a conflicted unpopulated submodule succeeds' '
test_must_fail git merge conflict2 &&
git rm submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -597,12 +581,12 @@ test_expect_success 'rm of a populated submodule with a .git directory fails eve
test_must_fail git rm submod &&
test -d submod &&
test -d submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
! test -s actual &&
test_must_fail git rm -f submod &&
test -d submod &&
test -d submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
! test -s actual &&
rm -rf submod
'
@@ -629,58 +613,52 @@ test_expect_success 'setup subsubmodule' '
test_expect_success 'rm recursively removes work tree of unmodified submodules' '
git rm submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
test_expect_success 'rm of a populated nested submodule with different nested HEAD fails unless forced' '
git reset --hard &&
git submodule update --recursive &&
- (cd submod/subsubmod &&
- git checkout HEAD^
- ) &&
+ git -C submod/subsubmod checkout HEAD^ &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
test_expect_success 'rm of a populated nested submodule with nested modifications fails unless forced' '
git reset --hard &&
git submodule update --recursive &&
- (cd submod/subsubmod &&
- echo X >empty
- ) &&
+ echo X >submod/subsubmod/empty &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
test_expect_success 'rm of a populated nested submodule with nested untracked files fails unless forced' '
git reset --hard &&
git submodule update --recursive &&
- (cd submod/subsubmod &&
- echo X >untracked
- ) &&
+ echo X >submod/subsubmod/untracked &&
test_must_fail git rm submod &&
test -d submod &&
test -f submod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect.modified actual &&
git rm -f submod &&
test ! -d submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
test_cmp expect actual
'
@@ -695,12 +673,12 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
test_must_fail git rm submod &&
test -d submod &&
test -d submod/subsubmod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
! test -s actual &&
test_must_fail git rm -f submod &&
test -d submod &&
test -d submod/subsubmod/.git &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
! test -s actual &&
rm -rf submod
'
@@ -716,7 +694,7 @@ test_expect_success 'checking out a commit after submodule removal needs manual
echo "?? submod/" >expected &&
test_cmp expected actual &&
rm -rf submod &&
- git status -s -uno --ignore-submodules=none > actual &&
+ git status -s -uno --ignore-submodules=none >actual &&
! test -s actual
'
--
2.11.0.rc2.35.g7af3268
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox