* [PATCH/RFC] git-gui: Fix author name encoding in Amend Last Commit.
From: bernhardu @ 2017-02-14 22:46 UTC (permalink / raw)
To: git; +Cc: Bernhard Übelacker
From: Bernhard Übelacker <bernhardu@mailbox.org>
In "New Commit" author name is set correctly.
But when doing "Amend Last Commit" the encoding gets wrong.
This patch adds in load_last_commit a similar assignment converting
to tcl encoding for commit_author as already exists for msg.
---
lib/commit.tcl | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/commit.tcl b/lib/commit.tcl
index 83620b7..f5357f2 100644
--- a/lib/commit.tcl
+++ b/lib/commit.tcl
@@ -46,6 +46,9 @@ You are currently in the middle of a merge that has not been fully completed. Y
set msg [encoding convertfrom $enc $msg]
}
set msg [string trim $msg]
+ if {$enc ne {}} {
+ set commit_author [encoding convertfrom $enc $commit_author]
+ }
} err]} {
error_popup [strcat [mc "Error loading commit data for amend:"] "\n\n$err"]
return
--
2.11.0
^ permalink raw reply related
* What's cooking in git.git (Feb 2017, #04; Tue, 14)
From: Junio C Hamano @ 2017-02-14 22:59 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.
Topic descriptions of some new topics I just wrote are all iffy.
Suggestion to clarify them are very much welcomed.
Oh, also I'd like to get pull requests for gitk and git-gui updates
soonish, if we are to have one during this cycle.
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]
* jh/preload-index-skip-skip (2017-02-10) 1 commit
- preload-index: avoid lstat for skip-worktree items
The preload-index code has been taught not to bother with the index
entries that are paths that are not checked out by "sparse checkout".
Will merge to and cook in 'next'.
* rs/cocci-check-free-only-null (2017-02-11) 1 commit
- cocci: detect useless free(3) calls
A new coccinelle rule that catches a check of !pointer before the
pointer is free(3)d, which most likely is a bug.
Will merge to 'next'.
* jk/doc-remote-helpers-markup-fix (2017-02-13) 1 commit
(merged to 'next' on 2017-02-14 at 95af1267c7)
+ docs/gitremote-helpers: fix unbalanced quotes
Doc markup fix.
Will merge to 'master'.
* jk/doc-submodule-markup-fix (2017-02-13) 1 commit
(merged to 'next' on 2017-02-14 at b2f807f7d8)
+ docs/git-submodule: fix unbalanced quote
Doc markup fix.
Will merge to 'master'.
* rs/ls-files-partial-optim (2017-02-13) 2 commits
- ls-files: move only kept cache entries in prune_cache()
- ls-files: pass prefix length explicitly to prune_cache()
"ls-files" run with pathspec has been micro-optimized to avoid one
extra call to memmove().
Will merge to 'next'.
* rs/strbuf-cleanup-in-rmdir-recursively (2017-02-13) 1 commit
- rm: reuse strbuf for all remove_dir_recursively() calls, again
Code clean-up.
Will merge to 'next'.
* tg/stash-doc-cleanup (2017-02-13) 1 commit
(merged to 'next' on 2017-02-14 at 5b9ffbc741)
+ Documentation/stash: remove mention of git reset --hard
(this branch is used by tg/stash-push.)
The documentation explained what "git stash" does to the working
tree (after stashing away the local changes) in terms of "reset
--hard", which was exposing an unnecessary implementation detail.
Will merge to 'master'.
* tg/stash-push (2017-02-13) 6 commits
- stash: allow pathspecs in the no verb form
- stash: use stash_push for no verb form
- stash: teach 'push' (and 'create') to honor pathspec
- stash: introduce new format create
- stash: add test for the create command line arguments
- stash: introduce push verb
(this branch uses tg/stash-doc-cleanup.)
Allow "git stash" to take pathspec so that the local changes can be
stashed away only partially.
Waiting for the review discussion to settle, followed by a reroll.
cf. <20170212215420.16701-1-t.gummerer@gmail.com>
* bc/object-id (2017-02-14) 19 commits
- wt-status: convert to struct object_id
- builtin/merge-base: convert to struct object_id
- object_id: use struct object_id in object iteration callbacks
- sha1_file: introduce an nth_packed_object_oid function
- refs: simplify parsing of reflog entries
- hex: introduce parse_oid_hex
- refs: convert each_reflog_ent_fn to struct object_id
- reflog-walk: convert struct reflog_info to struct object_id
- builtin/replace: convert to struct object_id
- object_id: convert remaining callers of resolve_refdup()
- builtin/merge: convert to struct object_id
- builtin/clone: convert to struct object_id
- builtin/branch: convert to struct object_id
- builtin/grep: convert to struct object_id
- builtin/fmt-merge-message: convert to struct object_id
- builtin/fast-export: convert to struct object_id
- builtin/describe: convert to struct object_id
- builtin/diff-tree: convert to struct object_id
- builtin/commit: convert to struct object_id
"uchar [40]" to "struct object_id" conversion continues.
* jk/grep-no-index-fix (2017-02-14) 7 commits
- grep: treat revs the same for --untracked as for --no-index
- grep: do not diagnose misspelt revs with --no-index
- grep: avoid resolving revision names in --no-index case
- grep: fix "--" rev/pathspec disambiguation
- grep: re-order rev-parsing loop
- grep: do not unnecessarily query repo for "--"
- grep: move thread initialization a little lower
The code to parse the command line "git grep <patterns>... <rev>
[[--] <pathspec>...]" has been cleaned up, and a handful of bugs
have been fixed (e.g. we used to check "--" if it is a rev).
Will merge to and cook in 'next'.
* jk/show-branch-lift-name-len-limit (2017-02-14) 3 commits
- show-branch: use skip_prefix to drop magic numbers
- show-branch: store resolved head in heap buffer
- show-branch: drop head_len variable
"git show-branch" expected there were only very short branch names
in the repository and used a fixed-length buffer to hold them
without checking for overflow.
Will merge to and cook in 'next'.
* js/mingw-isatty (2017-02-14) 1 commit
- mingw: make stderr unbuffered again
A hotfix for a topic already in 'master'.
Will merge to 'next'.
* lt/oneline-decoration-at-end (2017-02-14) 1 commit
- show decorations at the end of the line
The output from "git log --oneline --decorate" has been updated to
show the extra information at the end of the line, not near the
front.
Will merge to and cook in 'next'.
* jn/remote-helpers-with-git-dir (2017-02-14) 2 commits
- remote helpers: avoid blind fall-back to ".git" when setting GIT_DIR
- remote: avoid reading $GIT_DIR config in non-repo
"git ls-remote" and "git archive --remote" are designed to work
without being in a directory under Git's control. However, recent
updates revealed that we randomly look into a directory called
.git/ without actually doing necessary set-up when working in a
repository. Stop doing so.
Will merge to and cook in 'next'.
--------------------------------------------------
[Stalled]
* vn/xdiff-func-context (2017-01-15) 1 commit
- xdiff -W: relax end-of-file function detection
"git diff -W" has been taught to handle the case where a new
function is added at the end of the file better.
Will hold.
Discussion on an follow-up change to go back from the line that
matches the funcline to show comments before the function
definition has not resulted in an actionable conclusion.
* 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.
Expecting a reroll.
cf. <CAFZEwPPXPPHi8KiEGS9ggzNHDCGhuqMgH9Z8-Pf9GLshg8+LPA@mail.gmail.com>
cf. <CAFZEwPM9RSTGN54dzaw9gO9iZmsYjJ_d1SjUD4EzSDDbmh-XuA@mail.gmail.com>
* ls/filter-process-delayed (2017-01-08) 1 commit
. convert: add "status=delayed" to filter process protocol
Ejected, as does not build when merged to 'pu'.
* sh/grep-tree-obj-tweak-output (2017-01-20) 2 commits
- grep: use '/' delimiter for paths
- grep: only add delimiter if there isn't one already
"git grep", when fed a tree-ish as an input, shows each hit
prefixed with "<tree-ish>:<path>:<lineno>:". As <tree-ish> is
almost always either a commit or a tag that points at a commit, the
early part of the output "<tree-ish>:<path>" can be used as the
name of the blob and given to "git show". When <tree-ish> is a
tree given in the extended SHA-1 syntax (e.g. "<commit>:", or
"<commit>:<dir>"), however, this results in a string that does not
name a blob (e.g. "<commit>::<path>" or "<commit>:<dir>:<path>").
"git grep" has been taught to be a bit more intelligent about these
cases and omit a colon (in the former case) or use slash (in the
latter case) to produce "<commit>:<path>" and
"<commit>:<dir>/<path>" that can be used as the name of a blob.
Waiting for the review discussion to settle, followed by a reroll.
* 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]
* jk/alternate-ref-optim (2017-02-08) 11 commits
(merged to 'next' on 2017-02-10 at f26f32cff6)
+ receive-pack: avoid duplicates between our refs and alternates
+ receive-pack: treat namespace .have lines like alternates
+ receive-pack: fix misleading namespace/.have comment
+ receive-pack: use oidset to de-duplicate .have lines
+ add oidset API
+ fetch-pack: cache results of for_each_alternate_ref
+ for_each_alternate_ref: replace transport code with for-each-ref
+ for_each_alternate_ref: pass name/oid instead of ref struct
+ for_each_alternate_ref: use strbuf for path allocation
+ for_each_alternate_ref: stop trimming trailing slashes
+ for_each_alternate_ref: handle failure from real_pathdup()
Optimizes resource usage while enumerating refs from alternate
object store, to help receiving end of "push" that hosts a
repository with many "forks".
Will cook in 'next'.
* lt/pathspec-negative (2017-02-10) 2 commits
(merged to 'next' on 2017-02-10 at 8ea7874076)
+ pathspec: don't error out on all-exclusionary pathspec patterns
+ pathspec magic: add '^' as alias for '!'
The "negative" pathspec feature was somewhat more cumbersome to use
than necessary in that its short-hand used "!" which needed to be
escaped from shells, and it required "exclude from what?" specified.
Will cook in 'next'.
* nd/worktree-gc-protection (2017-02-08) 2 commits
- worktree.c: use submodule interface to access refs from another worktree
- refs.c: add resolve_ref_submodule()
(hopefully) a beginning of safer "git worktree" that is resistant
to "gc".
Michael had a suggestion for a (hopefully) better alternative way
to do this. Expecting a reroll (either a tenative but quicker way,
or a better but slower way).
cf. <CACsJy8Diy92CNbJ1OBn893VFFrSsxBFWSyQHjt_Dzq9x7jfibQ@mail.gmail.com>
* sb/push-options-via-transport (2017-02-08) 1 commit
(merged to 'next' on 2017-02-10 at 3e2d08e1fa)
+ push options: pass push options to the transport helper
The push-options given via the "--push-options" option were not
passed through to external remote helpers such as "smart HTTP" that
are invoked via the transport helper.
Will merge to 'master'.
* js/rebase-helper (2017-02-09) 2 commits
(merged to 'next' on 2017-02-14 at ae2474048e)
+ rebase -i: use the rebase--helper builtin
+ rebase--helper: add a builtin helper for interactive rebases
"git rebase -i" starts using the recently updated "sequencer" code.
Will cook in 'next'.
The change itself is small, but what it enables is rather a large
body of new code. We are getting there ;-)
* mh/submodule-hash (2017-02-13) 9 commits
(merged to 'next' on 2017-02-14 at 43f2dcbe29)
+ read_loose_refs(): read refs using resolve_ref_recursively()
+ files_ref_store::submodule: use NULL for the main repository
+ base_ref_store_init(): remove submodule argument
+ refs: push the submodule attribute down
+ refs: store submodule ref stores in a hashmap
+ register_ref_store(): new function
+ refs: remove some unnecessary handling of submodule == ""
+ refs: make some ref_store lookup functions private
+ refs: reorder some function definitions
Code and design clean-up for the refs API.
Will cook in 'next'.
The tip one is newer than the one posted to the list but was sent
privately by the author via his GitHub repository.
* jh/mingw-openssl-sha1 (2017-02-09) 1 commit
(merged to 'next' on 2017-02-10 at 084b3d8503)
+ mingw: use OpenSSL's SHA-1 routines
Windows port wants to use OpenSSL's implementation of SHA-1
routines, so let them.
Will cook in 'next'.
cf. <31bb0b9f-d498-24b3-57d5-9f34cb8e3914@kdbg.org>
* sb/doc-unify-bottom (2017-02-09) 1 commit
(merged to 'next' on 2017-02-10 at 7229c4c1f7)
+ Documentation: unify bottom "part of git suite" lines
Doc clean-up.
Will merge to 'master'.
* dt/gc-ignore-old-gc-logs (2017-02-13) 1 commit
- gc: ignore old gc.log files
A "gc.log" file left by a backgrounded "gc --auto" disables further
automatic gc; it has been taught to run at least once a day (by
default) by ignoring a stale "gc.log" file that is too old.
Will merge to and cook in 'next'.
This is v6 posted on Feb 10th.
* js/git-path-in-subdir (2017-02-10) 2 commits
- rev-parse: fix several options when running in a subdirectory
- rev-parse tests: add tests executed from a subdirectory
The "--git-path", "--git-common-dir", and "--shared-index-path"
options of "git rev-parse" did not produce usable output. They are
now updated to show the path to the correct file, relative to where
the caller is.
Waiting for Review/Ack.
cf. <cover.1486740772.git.johannes.schindelin@gmx.de>
* ls/p4-path-encoding (2017-02-10) 1 commit
- git-p4: fix git-p4.pathEncoding for removed files
When "git p4" imports changelist that removes paths, it failed to
convert pathnames when the p4 used encoding different from the one
used on the Git side. This has been corrected.
Will merge to 'next'.
* mh/ref-remove-empty-directory (2017-01-07) 23 commits
(merged to 'next' on 2017-02-10 at bcfd359e95)
+ files_transaction_commit(): clean up empty directories
+ try_remove_empty_parents(): teach to remove parents of reflogs, too
+ try_remove_empty_parents(): don't trash argument contents
+ try_remove_empty_parents(): rename parameter "name" -> "refname"
+ delete_ref_loose(): inline function
+ delete_ref_loose(): derive loose reference path from lock
+ log_ref_write_1(): inline function
+ log_ref_setup(): manage the name of the reflog file internally
+ log_ref_write_1(): don't depend on logfile argument
+ log_ref_setup(): pass the open file descriptor back to the caller
+ log_ref_setup(): improve robustness against races
+ log_ref_setup(): separate code for create vs non-create
+ log_ref_write(): inline function
+ rename_tmp_log(): improve error reporting
+ rename_tmp_log(): use raceproof_create_file()
+ lock_ref_sha1_basic(): use raceproof_create_file()
+ lock_ref_sha1_basic(): inline constant
+ raceproof_create_file(): new function
+ safe_create_leading_directories(): set errno on SCLD_EXISTS
+ safe_create_leading_directories_const(): preserve errno
+ t5505: use "for-each-ref" to test for the non-existence of references
+ refname_is_safe(): correct docstring
+ files_rename_ref(): tidy up whitespace
Deletion of a branch "foo/bar" could remove .git/refs/heads/foo
once there no longer is any other branch whose name begins with
"foo/", but we didn't do so so far. Now we do.
Will cook in 'next'.
* cw/completion (2017-02-03) 7 commits
(merged to 'next' on 2017-02-10 at b3a5cbf39c)
+ completion: recognize more long-options
+ completion: teach remote subcommands to complete options
+ completion: teach replace to complete options
+ completion: teach ls-remote to complete options
+ completion: improve bash completion for git-add
+ completion: add subcommand completion for rerere
+ completion: teach submodule subcommands to complete options
More command line completion (in contrib/) for recent additions.
Will merge to 'master'.
* cw/tag-reflog-message (2017-02-08) 1 commit
(merged to 'next' on 2017-02-10 at 3968b3a58b)
+ tag: generate useful reflog message
"git tag", because refs/tags/* doesn't keep reflog by default, did
not leave useful message when adding a new entry to reflog.
Will cook in 'next'.
* sg/completion (2017-02-13) 22 commits
(merged to 'next' on 2017-02-13 at 118c192874)
+ completion: restore removed line continuating backslash
(merged to 'next' on 2017-02-10 at 55b2785d89)
+ completion: cache the path to the repository
+ completion: extract repository discovery from __gitdir()
+ completion: don't guard git executions with __gitdir()
+ completion: consolidate silencing errors from git commands
+ completion: don't use __gitdir() for git commands
+ completion: respect 'git -C <path>'
+ rev-parse: add '--absolute-git-dir' option
+ completion: fix completion after 'git -C <path>'
+ completion: don't offer commands when 'git --opt' needs an argument
+ completion: list short refs from a remote given as a URL
+ completion: don't list 'HEAD' when trying refs completion outside of a repo
+ completion: list refs from remote when remote's name matches a directory
+ completion: respect 'git --git-dir=<path>' when listing remote refs
+ completion: fix most spots not respecting 'git --git-dir=<path>'
+ completion: ensure that the repository path given on the command line exists
+ completion tests: add tests for the __git_refs() helper function
+ completion tests: check __gitdir()'s output in the error cases
+ completion tests: consolidate getting path of current working directory
+ completion tests: make the $cur variable local to the test helper functions
+ completion tests: don't add test cruft to the test repository
+ completion: improve __git_refs()'s in-code documentation
(this branch is used by sg/completion-refs-speedup.)
Clean-up and updates to command line completion (in contrib/).
Will cook in 'next'.
* sg/completion-refs-speedup (2017-02-13) 13 commits
- squash! completion: fill COMPREPLY directly when completing refs
- completion: fill COMPREPLY directly when completing refs
- completion: list only matching symbolic and pseudorefs when completing refs
- completion: let 'for-each-ref' sort remote branches for 'checkout' DWIMery
- completion: let 'for-each-ref' filter remote branches for 'checkout' DWIMery
- completion: let 'for-each-ref' strip the remote name from remote branches
- completion: let 'for-each-ref' and 'ls-remote' filter matching refs
- completion: don't disambiguate short refs
- completion: don't disambiguate tags and branches
- completion: support excluding full refs
- completion: support completing full refs after '--option=refs/<TAB>'
- completion: wrap __git_refs() for better option parsing
- completion: remove redundant __gitcomp_nl() options from _git_commit()
(this branch uses sg/completion.)
The refs completion for large number of refs has been sped up,
partly by giving up disambiguating ambiguous refs and partly by
eliminating most of the shell processing between 'git for-each-ref'
and 'ls-remote' and Bash's completion facility.
Will hold.
* sk/parse-remote-cleanup (2017-02-06) 1 commit
(merged to 'next' on 2017-02-06 at 6ec89f72d5)
+ parse-remote: remove reference to unused op_prep
Code clean-up.
Undecided. There may be third-party scripts that are dot-sourcing
this one.
* jk/delta-chain-limit (2017-01-27) 2 commits
(merged to 'next' on 2017-02-06 at 9ff36ae9b2)
+ pack-objects: convert recursion to iteration in break_delta_chain()
+ pack-objects: enforce --depth limit in reused deltas
"git repack --depth=<n>" for a long time busted the specified depth
when reusing delta from existing packs. This has been corrected.
Will cook in 'next'.
* mm/merge-rename-delete-message (2017-01-30) 1 commit
(merged to 'next' on 2017-02-10 at 8bf8146029)
+ merge-recursive: make "CONFLICT (rename/delete)" message show both paths
When "git merge" detects a path that is renamed in one history
while the other history deleted (or modified) it, it now reports
both paths to help the user understand what is going on in the two
histories being merged.
Will cook in 'next'.
* rs/swap (2017-01-30) 5 commits
(merged to 'next' on 2017-02-10 at 5253797d0a)
+ graph: use SWAP macro
+ diff: use SWAP macro
+ use SWAP macro
+ apply: use SWAP macro
+ add SWAP macro
Code clean-up.
Will merge to 'master'.
* ps/urlmatch-wildcard (2017-02-01) 5 commits
(merged to 'next' on 2017-02-10 at 2ed9ea48ee)
+ urlmatch: allow globbing for the URL host part
+ urlmatch: include host in urlmatch ranking
+ urlmatch: split host and port fields in `struct url_info`
+ urlmatch: enable normalization of URLs with globs
+ mailmap: add Patrick Steinhardt's work address
The <url> part in "http.<url>.<variable>" configuration variable
can now be spelled with '*' that serves as wildcard.
E.g. "http.https://*.example.com.proxy" can be used to specify the
proxy used for https://a.example.com, https://b.example.com, etc.,
i.e. any host in the example.com domain.
Will cook in 'next'.
* sf/putty-w-args (2017-02-10) 5 commits
(merged to 'next' on 2017-02-14 at 7f157e7020)
+ connect.c: stop conflating ssh command names and overrides
+ connect: Add the envvar GIT_SSH_VARIANT and ssh.variant config
+ git_connect(): factor out SSH variant handling
+ connect: rename tortoiseplink and putty variables
+ connect: handle putty/plink also in GIT_SSH_COMMAND
The command line options for ssh invocation needs to be tweaked for
some implementations of SSH (e.g. PuTTY plink wants "-P <port>"
while OpenSSH wants "-p <port>" to specify port to connect to), and
the variant was guessed when GIT_SSH environment variable is used
to specify it. Extend the guess to the command specified by the
newer GIT_SSH_COMMAND and also core.sshcommand configuration
variable, and give an escape hatch for users to deal with
misdetected cases.
Will cook in 'next'.
* jk/describe-omit-some-refs (2017-01-23) 5 commits
(merged to 'next' on 2017-01-23 at f8a14b4996)
+ describe: teach describe negative pattern matches
+ describe: teach --match to accept multiple patterns
+ name-rev: add support to exclude refs by pattern match
+ name-rev: extend --refs to accept multiple patterns
+ doc: add documentation for OPT_STRING_LIST
"git describe" and "git name-rev" have been taught to take more
than one refname patterns to restrict the set of refs to base their
naming output on, and also learned to take negative patterns to
name refs not to be used for naming via their "--exclude" option.
Will cook in 'next'.
* sb/submodule-doc (2017-01-12) 2 commits
(merged to 'next' on 2017-02-10 at 5bfad5f30e)
+ submodule update documentation: don't repeat ourselves
+ submodule documentation: add options to the subcommand
Doc updates.
Will merge to 'master'.
* bw/attr (2017-02-01) 27 commits
(merged to 'next' on 2017-02-14 at d35c1d7e4a)
+ attr: reformat git_attr_set_direction() function
+ attr: push the bare repo check into read_attr()
+ attr: store attribute stack in attr_check structure
+ attr: tighten const correctness with git_attr and match_attr
+ attr: remove maybe-real, maybe-macro from git_attr
+ attr: eliminate global check_all_attr array
+ attr: use hashmap for attribute dictionary
+ attr: change validity check for attribute names to use positive logic
+ attr: pass struct attr_check to collect_some_attrs
+ 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 attr_check"
+ attr: (re)introduce git_check_attr() and struct attr_check
+ attr: rename function and struct related to checking attributes
+ attr.c: outline the future plans by heavily commenting
+ Documentation: fix a typo
+ attr.c: add push_stack() helper
+ attr: support quoting pathname patterns in C style
+ 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 gitattributes machinery is being taught to work better in a
multi-threaded environment.
Will cook in 'next'.
* nd/worktree-move (2017-01-27) 7 commits
. fixup! worktree move: new command
. 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()
"git worktree" learned move and remove subcommands.
Tentatively ejected as it seems to break 'pu' when merged.
* cc/split-index-config (2016-12-26) 21 commits
- Documentation/git-update-index: explain splitIndex.*
- Documentation/config: add splitIndex.sharedIndexExpire
- read-cache: use freshen_shared_index() in read_index_from()
- read-cache: refactor read_index_from()
- t1700: test shared index file expiration
- read-cache: unlink old sharedindex files
- config: add git_config_get_expiry() from gc.c
- read-cache: touch shared index files when used
- sha1_file: make check_and_freshen_file() non static
- Documentation/config: add splitIndex.maxPercentChange
- t1700: add tests for splitIndex.maxPercentChange
- read-cache: regenerate shared index if necessary
- config: add git_config_get_max_percent_split_change()
- Documentation/git-update-index: talk about core.splitIndex config var
- Documentation/config: add information for core.splitIndex
- t1700: add tests for core.splitIndex
- update-index: warn in case of split-index incoherency
- read-cache: add and then use tweak_split_index()
- split-index: add {add,remove}_split_index() functions
- config: add git_config_get_split_index()
- config: mark an error message up for translation
The experimental "split index" feature has gained a few
configuration variables to make it easier to use.
Waiting for review comments to be addressed.
cf. <20161226102222.17150-1-chriscool@tuxfamily.org>
cf. <a1a44640-ff6c-2294-72ac-46322eff8505@ramsayjones.plus.com>
* kn/ref-filter-branch-list (2017-02-07) 21 commits
(merged to 'next' on 2017-02-10 at 794bb8284d)
+ ref-filter: resurrect "strip" as a synonym to "lstrip"
(merged to 'next' on 2017-01-31 at e7592a5461)
+ 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: Do not abruptly die when using the 'lstrip=<N>' option
+ 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
The code to list branches in "git branch" has been consolidated
with the more generic ref-filter API.
Will cook in 'next'.
* 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/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'.
* 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.
--------------------------------------------------
[Discarded]
* 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?
* sb/push-make-submodule-check-the-default (2017-01-26) 2 commits
(merged to 'next' on 2017-01-26 at 5f4715cea6)
+ Revert "push: change submodule default to check when submodules exist"
(merged to 'next' on 2016-12-12 at 1863e05af5)
+ push: change submodule default to check when submodules exist
Turn the default of "push.recurseSubmodules" to "check" when
submodules seem to be in use.
Retracted.
^ permalink raw reply
* Re: [git-for-windows] Re: Continuous Testing of Git on Windows
From: Christian Couder @ 2017-02-14 23:00 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Schindelin, git-for-windows, git
In-Reply-To: <xmqqd1ek8oqo.fsf@gitster.mtv.corp.google.com>
On Tue, Feb 14, 2017 at 10:08 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
>> On Mon, 13 Feb 2017, Junio C Hamano wrote:
>>
>>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>>>
>>> > That is why I taught the Git for Windows CI job that tests the four
>>> > upstream Git integration branches to *also* bisect test breakages and
>>> > then upload comments to the identified commit on GitHub
>>>
>>> Good. I do not think it is useful to try 'pu' as an aggregate and
>>> expect it to always build and work [*1*], but your "bisect and
>>> pinpoint" approach makes it useful to identify individual topic that
>>> brings in a breakage.
>>
>> Sadly the many different merge bases[*1*] between `next` and `pu` (which
>> are the obvious good/bad points for bisecting automatically) bring my
>> build agents to its knees. I may have to disable the bisecting feature as
>> a consequence.
Yeah, this is a bug in the bisect algorithm. Fixing it is in the GSoC
2017 Ideas.
> Probably a less resource intensive approach is to find the tips of
> the topics not in 'next' but in 'pu' and test them. That would give
> you which topic(s) are problematic, which is a better starting point
> than "Oh, 'pu' does not build". After identifying which branch is
> problematic, bisection of individual topic would be of more manageable
> size.
It is still probably more resource intensive than it couls be.
[...]
> This is one of these times I wish "git bisect --first-parent" were
> available.
Implementing "git bisect --first-parent" is also part of the GSoC 2017 Ideas.
By the way it should not be very difficult as a patch to do this and
more was proposed a long time ago:
https://public-inbox.org/git/4D3CDDF9.6080405@intel.com/
> The above "log" gives me 27 merges right now, which
> should be bisectable within 5 rounds to identify a single broken
> topic (if there is only one breakage, that is).
^ permalink raw reply
* Re: [git-for-windows] Re: Continuous Testing of Git on Windows
From: Junio C Hamano @ 2017-02-14 23:11 UTC (permalink / raw)
To: Christian Couder; +Cc: Johannes Schindelin, git-for-windows, git
In-Reply-To: <CAP8UFD1+AgBVqSh=wHteM3uKO+55ZqqD4cHzBUfN0KTPXyvutQ@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
> By the way it should not be very difficult as a patch to do this and
> more was proposed a long time ago:
>
> https://public-inbox.org/git/4D3CDDF9.6080405@intel.com/
Thanks for a link. The one I found most interesting in the thread
is by Avery [*1*], where he explains why "first-parent" bisection
makes sense in "many people develop topics of their own, and they
are aggregated into an integration branch" environment:
Basically, we push/fetch *all* the branches from *everybody* into a
single repo, and build all of them as frequently as we can. If you
think about it, if you have all the branches that someone might have
pulled/merged from, then you don't have to think of the git history
as a whole complicated DAG; you can just think of it as a whole
bunch of separate chunks of linear history. Moreover, as long as
people are careful to only pull from a branch when that branch is
passing all tests - which you can easily see by looking at the
gitbuilder console - then playing inside each of these chunks of
linear history can help you figure out where particular bugs were
introduced during "messy" branches.
It also allows you a nice separation of concerns. The owner of the
mainline branch (the "integration manager" person) only really cares
about which branch they merged that caused a problem, because that
person doesn't want to fix bugs, he/she simply wants to know who
owns the failing branch, so that person can fix *their* bug and
their branch will merge without breaking things.
[Reference]
*1* https://public-inbox.org/git/AANLkTinwbm9gcZhGeQCbOEPov0_xV7uJyQvC7J13qO15@mail.gmail.com/
^ permalink raw reply
* Re: [git-for-windows] Re: Continuous Testing of Git on Windows
From: Philip Oakley @ 2017-02-14 23:27 UTC (permalink / raw)
To: Christian Couder, Junio C Hamano
Cc: Johannes Schindelin, git-for-windows, git
In-Reply-To: <CAP8UFD1+AgBVqSh=wHteM3uKO+55ZqqD4cHzBUfN0KTPXyvutQ@mail.gmail.com>
From: "Christian Couder" <christian.couder@gmail.com>
> On Tue, Feb 14, 2017 at 10:08 PM, Junio C Hamano <gitster@pobox.com>
> wrote:
>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>>
>>> On Mon, 13 Feb 2017, Junio C Hamano wrote:
>>>
>>>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>>>>
>>>> > That is why I taught the Git for Windows CI job that tests the four
>>>> > upstream Git integration branches to *also* bisect test breakages and
>>>> > then upload comments to the identified commit on GitHub
>>>>
>>>> Good. I do not think it is useful to try 'pu' as an aggregate and
>>>> expect it to always build and work [*1*], but your "bisect and
>>>> pinpoint" approach makes it useful to identify individual topic that
>>>> brings in a breakage.
>>>
>>> Sadly the many different merge bases[*1*] between `next` and `pu` (which
>>> are the obvious good/bad points for bisecting automatically) bring my
>>> build agents to its knees. I may have to disable the bisecting feature
>>> as
>>> a consequence.
>
> Yeah, this is a bug in the bisect algorithm. Fixing it is in the GSoC
> 2017 Ideas.
There are also a few ideas at the SO answers:
http://stackoverflow.com/a/5652323/717355
>
>> Probably a less resource intensive approach is to find the tips of
>> the topics not in 'next' but in 'pu' and test them. That would give
>> you which topic(s) are problematic, which is a better starting point
>> than "Oh, 'pu' does not build". After identifying which branch is
>> problematic, bisection of individual topic would be of more manageable
>> size.
>
> It is still probably more resource intensive than it couls be.
>
> [...]
>
>> This is one of these times I wish "git bisect --first-parent" were
>> available.
>
> Implementing "git bisect --first-parent" is also part of the GSoC 2017
> Ideas.
>
> By the way it should not be very difficult as a patch to do this and
> more was proposed a long time ago:
>
> https://public-inbox.org/git/4D3CDDF9.6080405@intel.com/
>
>> The above "log" gives me 27 merges right now, which
>> should be bisectable within 5 rounds to identify a single broken
>> topic (if there is only one breakage, that is).
>
--
Philip
^ permalink raw reply
* Re: [RFC-PATCHv2] submodules: add a background story
From: Junio C Hamano @ 2017-02-14 23:31 UTC (permalink / raw)
To: Stefan Beller; +Cc: git@vger.kernel.org, Brandon Williams
In-Reply-To: <CAGZ79kaeVrW3_kUWWxBMztOPuWY_V6XP2SUDyw8mmQ6peFZwdw@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
> I claim that the exposure into .gitmodules combined with
> the extreme similarity to its path is confusing. Maybe this
> can be fixed by a different default name.
I think that this may be worth thinking about it further.
The names are something the end users are not supposed to change,
and one way to ensure that is to make .gitmodules file a binary
black box that can only be updated with a specialized tool---as long
as the tool does not allow updating the "name" field, you wouldn't
risk them mucking with it. Limiting the update to a specialized
tool also would give us a single place to ensure that it is globally
unique across the history of the project (well, at least the part of
the history that is visible to your repository).
Of course, being "one way" to do so does not mean it is the only
way, or it is the best way. Keeping the information in a text file
lets you merge them more easily when you add a submodule B while I
added a submodule C, for example, and having a human readble name
lets us learn from the output of "git log -p .gitmodules" that the
repository of the "linux-kernel" submodule we use in our appliance
used to live at linux-2.6.git but has moved to linux.git over time
(for the latter use case to work well, we cannot change the name to
something unreadable by humans like uuid---discouraging people from
modifying and making them unreadble are two different things).
^ permalink raw reply
* Re: [git-for-windows] Re: Continuous Testing of Git on Windows
From: Junio C Hamano @ 2017-02-14 23:35 UTC (permalink / raw)
To: Philip Oakley; +Cc: Christian Couder, Johannes Schindelin, git-for-windows, git
In-Reply-To: <E2C1B7A8FBF94C8CB1C9C5754D882800@PhilipOakley>
"Philip Oakley" <philipoakley@iee.org> writes:
> There are also a few ideas at the SO answers:
> http://stackoverflow.com/a/5652323/717355
I vaguely recall that I saw somebody said the same "mark tips of
topics as good" on the list and answered with why it does not quite
work, though.
^ permalink raw reply
* Re: Feature request: flagging “volatile” branches for integration/development
From: Herbert, Marc @ 2017-02-15 0:13 UTC (permalink / raw)
To: git; +Cc: Josh Triplett
In-Reply-To: <CACsJy8A5AXs5jQUQAdb=tuBzWYKNbu5DPnQ88DXott8ht61egA@mail.gmail.com>
[apologies for the accidental "smart" quotes and the resulting UTF8
encoding of the subject]
On 04/02/2017 06:01, Duy Nguyen wrote:
>
> But that would be local information only. We don't have ways to
> transfer branch metadata (and we definitely don't want to just share
> .git/config file with everybody). I suppose extending git protocol for
> this is not hard (e.g. appending metadata in the "have" lines).
Thanks Duy. So did you mean:
[ X ] send (big!) patches ?
> The hard part may be policy (e.g. what if the user does not want a branch
> to be treated volatile by various commands even if it receives such
> flag from a git server).
There would be instant, human-readable value in such a new "volatile"
flag. Machine use and policies can be discussed later. These will be
easier to prototype, experiment and refine once the flag exists.
----
Interestingly, it was pointed to me (thanks Calvin) that GitLab has
implemented this volatile flag exactly. It's called... "work in progress":
https://docs.gitlab.com/ee/user/project/merge_requests/work_in_progress_merge_requests.html
I'm not familiar with GitHub, however browsing its documentation the
(in)existence of a pull request seems equivalent to a (non-)volatile
flag. Just like a pull request by email without the need to find and search
a mailing-list.
I'm familiar with Gerrit and there's no strict equivalent to a volatile
flag, however it's:
- totally obvious when the commit has been accepted and merged - hence
its SHA1 final.
- usually fairly clear whether the code is still WIP or near the
"pull request" stage based on: how the code review is going, approvals
and other metadata.
Long story short: to integrate code reviews and source control these
systems overload git with a ton of metadata so it's no surprise to
always find in them something that more or less looks like a "volatile"
flag. I guess this leads to the more general question of core git possibly
implementing some generic metadata/property system (key,value pairs?
everything is a ref?) to better support code review and other
git-based software... Now I bet this on the other hand must have been
discussed (and rejected?) before, any pointer?
Marc
^ permalink raw reply
* Re: [RFC PATCH] show decorations at the end of the line
From: Jeff King @ 2017-02-15 0:29 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Linus Torvalds, Git Mailing List
In-Reply-To: <xmqqr330779h.fsf@gitster.mtv.corp.google.com>
On Tue, Feb 14, 2017 at 02:11:06PM -0800, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
> > Thanks. We'd need to update the tests that expects the old style
> > output, though.
>
> The updates to the expectation look like this (already squashed).
> The --source decorations in 4202 are also shown at the end, which
> probably is in line with the way --show-decorations adds them at the
> end of the line, but was somewhat surprising from reading only the
> log message.
Hrm, that does surprise me. I'm not sure if that's desirable or not. I
do think some of the "nobody could possibly be parsing these" arguments
about decorations do not apply to --source (and also, they're harder for
humans to pick out from the end of the line as they lack punctuation and
color).
-Peff
^ permalink raw reply
* [RFCv3 PATCH 00/14] Checkout aware of Submodules!
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
previous work:
https://public-inbox.org/git/20161203003022.29797-1-sbeller@google.com/
v3:
* moved tests from t2013 to the generic submodule library.
* factored out the refactoring patches to be up front
* As I redid the complete implementation, I have the impression this time
it is cleaner than previous versions.
I think we still have to fix the corner cases of directory/file/submodule
conflicts before merging, but this serves as a status update on my current
way of thinking how to implement the worktree commands being aware of
submodules.
Thanks,
Stefan
v2:
* based on top of the series sent out an hour ago
"[PATCHv4 0/5] submodule embedgitdirs"
* Try to embed a submodule if we need to remove it.
* Strictly do not change behavior if not giving the new flag.
* I think I missed some review comments from v1, but I'd like to get
the current state out over the weekend, as a lot has changed so far.
On Monday I'll go through the previous discussion with a comb to see
if I missed something.
v1:
When working with submodules, nearly anytime after checking out
a different state of the projects, that has submodules changed
you'd run "git submodule update" with a current version of Git.
There are two problems with this approach:
* The "submodule update" command is dangerous as it
doesn't check for work that may be lost in the submodule
(e.g. a dangling commit).
* you may forget to run the command as checkout is supposed
to do all the work for you.
Integrate updating the submodules into git checkout, with the same
safety promises that git-checkout has, i.e. not throw away data unless
asked to. This is done by first checking if the submodule is at the same
sha1 as it is recorded in the superproject. If there are changes we stop
proceeding the checkout just like it is when checking out a file that
has local changes.
The integration happens in the code that is also used in other commands
such that it will be easier in the future to make other commands aware
of submodule.
This also solves d/f conflicts in case you replace a file/directory
with a submodule or vice versa.
The patches are still a bit rough, but the overall series seems
promising enough to me that I want to put it out here.
Any review, specifically on the design level welcome!
Thanks,
Stefan
Stefan Beller (14):
lib-submodule-update.sh: reorder create_lib_submodule_repo
lib-submodule-update.sh: define tests for recursing into submodules
make is_submodule_populated gently
connect_work_tree_and_git_dir: safely create leading directories
update submodules: add submodule config parsing
update submodules: add a config option to determine if submodules are
updated
update submodules: introduce is_interesting_submodule
update submodules: move up prepare_submodule_repo_env
update submodules: add submodule_go_from_to
unpack-trees: pass old oid to verify_clean_submodule
unpack-trees: check if we can perform the operation for submodules
read-cache: remove_marked_cache_entries to wipe selected submodules.
entry.c: update submodules when interesting
builtin/checkout: add --recurse-submodules switch
Documentation/git-checkout.txt | 7 +
builtin/checkout.c | 28 +++
builtin/grep.c | 2 +-
dir.c | 2 +
entry.c | 28 +++
read-cache.c | 3 +
submodule-config.c | 22 ++
submodule-config.h | 17 +-
submodule.c | 216 +++++++++++++++--
submodule.h | 16 +-
t/lib-submodule-update.sh | 534 +++++++++++++++++++++++++++++++++++++++--
t/t2013-checkout-submodule.sh | 5 +
unpack-trees.c | 115 +++++++--
unpack-trees.h | 1 +
14 files changed, 936 insertions(+), 60 deletions(-)
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply
* [PATCH 01/14] lib-submodule-update.sh: reorder create_lib_submodule_repo
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
Redraw the ASCII art describing the setup using more space, such that
it is easier to understand. The leaf commits are now ordered the same
way the actual code is ordered.
Add empty lines to the setup code separating each of the leaf commits,
each starting with a "checkout -b".
Signed-off-by: Stefan Beller <sbeller@google.com>
---
t/lib-submodule-update.sh | 49 ++++++++++++++++++++++++++++-------------------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index 915eb4a7c6..61c54f2098 100755
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -15,22 +15,27 @@
# - Tracked file replaced by submodule (replace_sub1_with_file =>
# replace_file_with_sub1)
#
-# --O-----O
-# / ^ replace_directory_with_sub1
-# / replace_sub1_with_directory
-# /----O
-# / ^
-# / modify_sub1
-# O------O-------O
-# ^ ^\ ^
-# | | \ remove_sub1
-# | | -----O-----O
-# | | \ ^ replace_file_with_sub1
-# | | \ replace_sub1_with_file
-# | add_sub1 --O-----O
-# no_submodule ^ valid_sub1
-# invalid_sub1
+# ----O
+# / ^
+# / remove_sub1
+# /
+# add_sub1 /-------O
+# | / ^
+# | / modify_sub1
+# v/
+# O------O-----------O---------O
+# ^ \ ^ replace_directory_with_sub1
+# | \ replace_sub1_with_directory
+# no_submodule \
+# --------O---------O
+# \ ^ replace_file_with_sub1
+# \ replace_sub1_with_file
+# \
+# ----O---------O
+# ^ valid_sub1
+# invalid_sub1
#
+
create_lib_submodule_repo () {
git init submodule_update_repo &&
(
@@ -49,10 +54,11 @@ create_lib_submodule_repo () {
git config submodule.sub1.ignore all &&
git add .gitmodules &&
git commit -m "Add sub1" &&
- git checkout -b remove_sub1 &&
+
+ git checkout -b remove_sub1 add_sub1&&
git revert HEAD &&
- git checkout -b "modify_sub1" "add_sub1" &&
+ git checkout -b modify_sub1 add_sub1 &&
git submodule update &&
(
cd sub1 &&
@@ -67,7 +73,7 @@ create_lib_submodule_repo () {
git add sub1 &&
git commit -m "Modify sub1" &&
- git checkout -b "replace_sub1_with_directory" "add_sub1" &&
+ git checkout -b replace_sub1_with_directory add_sub1 &&
git submodule update &&
git -C sub1 checkout modifications &&
git rm --cached sub1 &&
@@ -75,22 +81,25 @@ create_lib_submodule_repo () {
git config -f .gitmodules --remove-section "submodule.sub1" &&
git add .gitmodules sub1/* &&
git commit -m "Replace sub1 with directory" &&
+
git checkout -b replace_directory_with_sub1 &&
git revert HEAD &&
- git checkout -b "replace_sub1_with_file" "add_sub1" &&
+ git checkout -b replace_sub1_with_file add_sub1 &&
git rm sub1 &&
echo "content" >sub1 &&
git add sub1 &&
git commit -m "Replace sub1 with file" &&
+
git checkout -b replace_file_with_sub1 &&
git revert HEAD &&
- git checkout -b "invalid_sub1" "add_sub1" &&
+ git checkout -b invalid_sub1 add_sub1 &&
git update-index --cacheinfo 160000 0123456789012345678901234567890123456789 sub1 &&
git commit -m "Invalid sub1 commit" &&
git checkout -b valid_sub1 &&
git revert HEAD &&
+
git checkout master
)
}
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 02/14] lib-submodule-update.sh: define tests for recursing into submodules
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
Currently lib-submodule-update.sh provides 2 functions
test_submodule_switch and test_submodule_forced_switch that are used by a
variety of tests to ensure that submodules behave as expected. The current
expected behavior is that submodules are not touched at all (see
42639d2317a for the exact setup).
In the future we want to teach all these commands to properly recurse
into submodules. To do that, we'll add two testing functions to
submodule-update-lib.sh test_submodule_switch_recursing and
test_submodule_forced_switch_recursing.
These two functions behave in analogy to the already existing functions
just with a different expectation on submodule behavior. The submodule
in the working tree is expected to be updated to the recorded submodule
version. The behavior is analogous to e.g. the behavior of files in a
nested directory in the working tree, where a change to the working tree
handles any arising directory/file conflicts just fine.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
t/lib-submodule-update.sh | 474 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 472 insertions(+), 2 deletions(-)
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index 61c54f2098..7c8c557572 100755
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -4,6 +4,7 @@
# - New submodule (no_submodule => add_sub1)
# - Removed submodule (add_sub1 => remove_sub1)
# - Updated submodule (add_sub1 => modify_sub1)
+# - Updated submodule recursively (modify_sub1 => modify_sub1_recursively)
# - Submodule updated to invalid commit (add_sub1 => invalid_sub1)
# - Submodule updated from invalid commit (invalid_sub1 => valid_sub1)
# - Submodule replaced by tracked files in directory (add_sub1 =>
@@ -19,8 +20,8 @@
# / ^
# / remove_sub1
# /
-# add_sub1 /-------O
-# | / ^
+# add_sub1 /-------O---------O
+# | / ^ modify_sub1_recursive
# | / modify_sub1
# v/
# O------O-----------O---------O
@@ -73,6 +74,14 @@ create_lib_submodule_repo () {
git add sub1 &&
git commit -m "Modify sub1" &&
+ git checkout -b modify_sub1_recursively modify_sub1 &&
+ git -C sub1 checkout -b "add_nested_sub" &&
+ git -C sub1 submodule add --branch no_submodule ./. sub2 &&
+ git -C sub1 commit -a -m "add a nested submodule" &&
+ git add sub1 &&
+ git commit -a -m "update submodule, that updates a nested submodule" &&
+ git -C sub1 submodule deinit -f --all &&
+
git checkout -b replace_sub1_with_directory add_sub1 &&
git submodule update &&
git -C sub1 checkout modifications &&
@@ -139,6 +148,15 @@ test_git_directory_is_unchanged () {
)
}
+test_git_directory_exists() {
+ test -e ".git/modules/$1" &&
+ if test -f sub1/.git
+ then
+ # does core.worktree point at the right place?
+ test "$(git -C .git/modules/$1 config core.worktree)" = "../../../$1"
+ fi
+}
+
# Helper function to be executed at the start of every test below, it sets up
# the submodule repo if it doesn't exist and configures the most problematic
# settings for diff.ignoreSubmodules.
@@ -169,6 +187,18 @@ reset_work_tree_to () {
)
}
+reset_work_tree_to_interested () {
+ reset_work_tree_to $1 &&
+ # indicate we are interested in the submodule:
+ git -C submodule_update config submodule.sub1.url "bogus" &&
+ # also have it available:
+ if ! test -d submodule_update/.git/modules/sub1
+ then
+ mkdir submodule_update/.git/modules &&
+ cp -r submodule_update_repo/.git/modules/sub1 submodule_update/.git/modules/sub1
+ fi
+}
+
# Test that the superproject contains the content according to commit "$1"
# (the work tree must match the index for everything but submodules but the
# index must exactly match the given commit including any submodule SHA-1s).
@@ -684,3 +714,443 @@ test_submodule_forced_switch () {
)
'
}
+
+# Test that submodule contents are correctly updated when switching
+# between commits that change a submodule.
+# Test that the following transitions are correctly handled:
+# (These tests are also above in the case where we expect no change
+# in the submodule)
+# - Updated submodule
+# - New submodule
+# - Removed submodule
+# - Directory containing tracked files replaced by submodule
+# - Submodule replaced by tracked files in directory
+# - Submodule replaced by tracked file with the same name
+# - tracked file replaced by submodule
+#
+# New test cases
+# - Removing a submodule with a git directory absorbs the submodules
+# git directory first into the superproject.
+
+test_submodule_switch_recursing () {
+ command="$1"
+ ######################### Appearing submodule #########################
+ # Switching to a commit letting a submodule appear checks it out ...
+ test_expect_success "$command: added submodule is checked out" '
+ prolog &&
+ reset_work_tree_to_interested no_submodule &&
+ (
+ cd submodule_update &&
+ git branch -t add_sub1 origin/add_sub1 &&
+ $command add_sub1 &&
+ test_superproject_content origin/add_sub1 &&
+ test_submodule_content sub1 origin/add_sub1
+ )
+ '
+ # ... ignoring an empty existing directory ...
+ test_expect_success "$command: added submodule is checked out in empty dir" '
+ prolog &&
+ reset_work_tree_to_interested no_submodule &&
+ (
+ cd submodule_update &&
+ mkdir sub1 &&
+ git branch -t add_sub1 origin/add_sub1 &&
+ $command add_sub1 &&
+ test_superproject_content origin/add_sub1 &&
+ test_submodule_content sub1 origin/add_sub1
+ )
+ '
+ # ... unless there is an untracked file in its place.
+ test_expect_success "$command: added submodule doesn't remove untracked file with same name" '
+ prolog &&
+ reset_work_tree_to_interested no_submodule &&
+ (
+ cd submodule_update &&
+ git branch -t add_sub1 origin/add_sub1 &&
+ : >sub1 &&
+ test_must_fail $command add_sub1 &&
+ test_superproject_content origin/no_submodule &&
+ test_must_be_empty sub1
+ )
+ '
+ # ... but an ignored file is fine.
+ test_expect_success "$command: added submodule removes an untracked ignored file" '
+ test_when_finished "rm submodule_update/.git/info/exclude" &&
+ prolog &&
+ reset_work_tree_to_interested no_submodule &&
+ (
+ cd submodule_update &&
+ git branch -t add_sub1 origin/add_sub1 &&
+ : >sub1 &&
+ echo sub1 > .git/info/exclude
+ $command add_sub1 &&
+ test_superproject_content origin/add_sub1 &&
+ test_submodule_content sub1 origin/add_sub1
+ )
+ '
+ # Replacing a tracked file with a submodule produces a checked out submodule
+ test_expect_success "$command: replace tracked file with submodule checks out submodule" '
+ prolog &&
+ reset_work_tree_to_interested replace_sub1_with_file &&
+ (
+ cd submodule_update &&
+ git branch -t replace_file_with_sub1 origin/replace_file_with_sub1 &&
+ $command replace_file_with_sub1 &&
+ test_superproject_content origin/replace_file_with_sub1 &&
+ test_submodule_content sub1 origin/replace_file_with_sub1
+ )
+ '
+ # ... as does removing a directory with tracked files with a submodule.
+ test_expect_success "$command: replace directory with submodule" '
+ prolog &&
+ reset_work_tree_to_interested replace_sub1_with_directory &&
+ (
+ cd submodule_update &&
+ git branch -t replace_directory_with_sub1 origin/replace_directory_with_sub1 &&
+ $command replace_directory_with_sub1 &&
+ test_superproject_content origin/replace_directory_with_sub1 &&
+ test_submodule_content sub1 origin/replace_directory_with_sub1
+ )
+ '
+
+ ######################## Disappearing submodule #######################
+ # Removing a submodule removes its work tree ...
+ test_expect_success "$command: removed submodule removes submodules working tree" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t remove_sub1 origin/remove_sub1 &&
+ $command remove_sub1 &&
+ test_superproject_content origin/remove_sub1 &&
+ ! test -e sub1
+ )
+ '
+ # ... absorbing a .git directory along the way.
+ test_expect_success "$command: removed submodule absorbs submodules .git directory" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t remove_sub1 origin/remove_sub1 &&
+ replace_gitfile_with_git_dir sub1 &&
+ rm -rf .git/modules &&
+ $command remove_sub1 &&
+ test_superproject_content origin/remove_sub1 &&
+ ! test -e sub1 &&
+ test_git_directory_exists sub1
+ )
+ '
+ # Replacing a submodule with files in a directory must succeeds
+ # when the submodule is clean
+ test_expect_success "$command: replace submodule with a directory" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t replace_sub1_with_directory origin/replace_sub1_with_directory &&
+ $command replace_sub1_with_directory &&
+ test_superproject_content origin/replace_sub1_with_directory &&
+ test_submodule_content sub1 origin/replace_sub1_with_directory
+ )
+ '
+ # ... absorbing a .git directory.
+ test_expect_success "$command: replace submodule containing a .git directory with a directory must absorb the git dir" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t replace_sub1_with_directory origin/replace_sub1_with_directory &&
+ replace_gitfile_with_git_dir sub1 &&
+ rm -rf .git/modules &&
+ $command replace_sub1_with_directory &&
+ test_superproject_content origin/replace_sub1_with_directory &&
+ test_git_directory_exists sub1
+ )
+ '
+
+ # Replacing it with a file ...
+ test_expect_success "$command: replace submodule with a file" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
+ $command replace_sub1_with_file &&
+ test_superproject_content origin/replace_sub1_with_file &&
+ test -f sub1
+ )
+ '
+
+ # ... must check its local work tree for untracked files
+ test_expect_success "$command: replace submodule with a file must fail with untracked files" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
+ : >sub1/untrackedfile &&
+ test_must_fail $command replace_sub1_with_file &&
+ test_superproject_content origin/add_sub1 &&
+ test_submodule_content sub1 origin/add_sub1
+ )
+ '
+
+ # ... and ignored files are ignroed
+ test_expect_success "$command: replace submodule with a file works ignores ignored files in submodule" '
+ test_when_finished "rm submodule_update/.git/modules/sub1/info/exclude" &&
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
+ : >sub1/ignored &&
+ $command replace_sub1_with_file &&
+ test_superproject_content origin/replace_sub1_with_file &&
+ test -f sub1
+ )
+ '
+
+ ########################## Modified submodule #########################
+ # Updating a submodule sha1 updates the submodule's work tree
+ test_expect_success "$command: modified submodule updates submodule work tree" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t modify_sub1 origin/modify_sub1 &&
+ $command modify_sub1 &&
+ test_superproject_content origin/modify_sub1 &&
+ test_submodule_content sub1 origin/modify_sub1
+ )
+ '
+
+ # Updating a submodule to an invalid sha1 doesn't update the
+ # superproject nor the submodule's work tree.
+ test_expect_success "$command: updating to a missing submodule commit fails" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t invalid_sub1 origin/invalid_sub1 &&
+ test_must_fail $command invalid_sub1 &&
+ test_superproject_content origin/add_sub1 &&
+ test_submodule_content sub1 origin/add_sub1
+ )
+ '
+
+ test_expect_success "$command: modified submodule updates submodule recursively" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t modify_sub1_recursively origin/modify_sub1_recursively &&
+ $command modify_sub1_recursively &&
+ test_superproject_content origin/modify_sub1_recursively &&
+ test_submodule_content sub1 origin/modify_sub1_recursively
+ test_submodule_content sub1/sub2
+ )
+ '
+}
+
+# Test that submodule contents are updated when switching between commits
+# that change a submodule, but throwing away local changes in
+# the superproject as well as the submodule is allowed.
+test_submodule_forced_switch_recursing () {
+ command="$1"
+ ######################### Appearing submodule #########################
+ # Switching to a commit letting a submodule appear creates empty dir ...
+ test_expect_success "$command: added submodule is checked out" '
+ prolog &&
+ reset_work_tree_to_interested no_submodule &&
+ (
+ cd submodule_update &&
+ git branch -t add_sub1 origin/add_sub1 &&
+ $command add_sub1 &&
+ test_superproject_content origin/add_sub1 &&
+ test_submodule_content sub1 origin/add_sub1
+ )
+ '
+ # ... and doesn't care if it already exists ...
+ test_expect_success "$command: added submodule ignores empty directory" '
+ prolog &&
+ reset_work_tree_to_interested no_submodule &&
+ (
+ cd submodule_update &&
+ git branch -t add_sub1 origin/add_sub1 &&
+ mkdir sub1 &&
+ $command add_sub1 &&
+ test_superproject_content origin/add_sub1 &&
+ test_submodule_content sub1 origin/add_sub1
+ )
+ '
+ # ... not caring about an untracked file either
+ test_expect_success "$command: added submodule does remove untracked unignored file with same name when forced" '
+ prolog &&
+ reset_work_tree_to_interested no_submodule &&
+ (
+ cd submodule_update &&
+ git branch -t add_sub1 origin/add_sub1 &&
+ >sub1 &&
+ $command add_sub1 &&
+ test_superproject_content origin/add_sub1 &&
+ test_submodule_content sub1 origin/add_sub1
+ )
+ '
+ # Replacing a tracked file with a submodule checks out the submodule
+ test_expect_success "$command: replace tracked file with submodule populates the submodule" '
+ prolog &&
+ reset_work_tree_to_interested replace_sub1_with_file &&
+ (
+ cd submodule_update &&
+ git branch -t replace_file_with_sub1 origin/replace_file_with_sub1 &&
+ $command replace_file_with_sub1 &&
+ test_superproject_content origin/replace_file_with_sub1 &&
+ test_submodule_content sub1 origin/replace_file_with_sub1
+ )
+ '
+ # ... as does removing a directory with tracked files with a
+ # submodule.
+ test_expect_success "$command: replace directory with submodule" '
+ prolog &&
+ reset_work_tree_to_interested replace_sub1_with_directory &&
+ (
+ cd submodule_update &&
+ git branch -t replace_directory_with_sub1 origin/replace_directory_with_sub1 &&
+ $command replace_directory_with_sub1 &&
+ test_superproject_content origin/replace_directory_with_sub1 &&
+ test_submodule_content sub1 origin/replace_directory_with_sub1
+ )
+ '
+
+ ######################## Disappearing submodule #######################
+ # Removing a submodule doesn't remove its work tree ...
+ test_expect_success "$command: removed submodule leaves submodule directory and its contents in place" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t remove_sub1 origin/remove_sub1 &&
+ $command remove_sub1 &&
+ test_superproject_content origin/remove_sub1 &&
+ ! test -e sub1
+ )
+ '
+ # ... especially when it contains a .git directory.
+ test_expect_success "$command: removed submodule leaves submodule containing a .git directory alone" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t remove_sub1 origin/remove_sub1 &&
+ replace_gitfile_with_git_dir sub1 &&
+ rm -rf .git/modules/sub1 &&
+ $command remove_sub1 &&
+ test_superproject_content origin/remove_sub1 &&
+ test_git_directory_exists sub1 &&
+ ! test -e sub1
+ )
+ '
+ # Replacing a submodule with files in a directory ...
+ test_expect_success "$command: replace submodule with a directory" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t replace_sub1_with_directory origin/replace_sub1_with_directory &&
+ test_must_fail $command replace_sub1_with_directory &&
+ test_superproject_content origin/replace_sub1_with_directory
+ )
+ '
+ # ... absorbing a .git directory.
+ test_expect_success "$command: replace submodule containing a .git directory with a directory must fail" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t replace_sub1_with_directory origin/replace_sub1_with_directory &&
+ replace_gitfile_with_git_dir sub1 &&
+ rm -rf .git/modules/sub1 &&
+ $command replace_sub1_with_directory &&
+ test_superproject_content origin/replace_sub1_with_directory &&
+ test_submodule_content sub1 origin/modify_sub1
+ test_git_directory_exists sub1
+ )
+ '
+ # Replacing it with a file
+ test_expect_success "$command: replace submodule with a file" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
+ $command replace_sub1_with_file &&
+ test_superproject_content origin/replace_sub1_with_file
+ )
+ '
+
+ # ... even if the submodule contains ignored files
+ test_expect_success "$command: replace submodule with a file ignoring ignored files" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
+ : > sub1/expect &&
+ $command replace_sub1_with_file &&
+ test_superproject_content origin/replace_sub1_with_file
+ )
+ '
+
+ # ... but stops for untracked files that would be lost
+ test_expect_success "$command: replace submodule with a file" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
+ : > sub1/untracked_file &&
+ test_must_fail $command replace_sub1_with_file &&
+ test_superproject_content origin/add_sub1 &&
+ test -f sub1/untracked_file
+ )
+ '
+
+ ########################## Modified submodule #########################
+ # Updating a submodule sha1 updates the submodule's work tree
+ test_expect_success "$command: modified submodule updates submodule work tree" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t modify_sub1 origin/modify_sub1 &&
+ $command modify_sub1 &&
+ test_superproject_content origin/modify_sub1 &&
+ test_submodule_content sub1 origin/modify_sub1
+ )
+ '
+ # Updating a submodule to an invalid sha1 doesn't update the
+ # submodule's work tree, subsequent update will fail
+ test_expect_success "$command: modified submodule does not update submodule work tree to invalid commit" '
+ prolog &&
+ reset_work_tree_to_interested add_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t invalid_sub1 origin/invalid_sub1 &&
+ test_must_fail $command invalid_sub1 &&
+ test_superproject_content origin/add_sub1 &&
+ test_submodule_content sub1 origin/add_sub1
+ )
+ '
+ # Updating a submodule from an invalid sha1 updates
+ test_expect_success "$command: modified submodule does not update submodule work tree from invalid commit" '
+ prolog &&
+ reset_work_tree_to_interested invalid_sub1 &&
+ (
+ cd submodule_update &&
+ git branch -t valid_sub1 origin/valid_sub1 &&
+ test_must_fail $command valid_sub1 &&
+ test_superproject_content origin/invalid_sub1
+ )
+ '
+}
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 05/14] update submodules: add submodule config parsing
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
Similar to b33a15b08 (push: add recurseSubmodules config option,
2015-11-17) and 027771fcb1 (submodule: allow erroneous values for the
fetchRecurseSubmodules option, 2015-08-17), we add submodule-config code
that is later used to parse whether we are interested in updating
submodules.
We need the `die_on_error` parameter to be able to call this parsing
function for the config file as well, which if incorrect lets Git die.
As we're just touching the header file, also mark all functions extern.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
submodule-config.c | 22 ++++++++++++++++++++++
submodule-config.h | 17 +++++++++--------
2 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/submodule-config.c b/submodule-config.c
index 93453909cf..93f01c4378 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -234,6 +234,28 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
return parse_fetch_recurse(opt, arg, 1);
}
+static int parse_update_recurse(const char *opt, const char *arg,
+ int die_on_error)
+{
+ switch (git_config_maybe_bool(opt, arg)) {
+ case 1:
+ return RECURSE_SUBMODULES_ON;
+ case 0:
+ return RECURSE_SUBMODULES_OFF;
+ default:
+ if (!strcmp(arg, "checkout"))
+ return RECURSE_SUBMODULES_ON;
+ if (die_on_error)
+ die("bad %s argument: %s", opt, arg);
+ return RECURSE_SUBMODULES_ERROR;
+ }
+}
+
+int parse_update_recurse_submodules_arg(const char *opt, const char *arg)
+{
+ return parse_update_recurse(opt, arg, 1);
+}
+
static int parse_push_recurse(const char *opt, const char *arg,
int die_on_error)
{
diff --git a/submodule-config.h b/submodule-config.h
index 70f19363fd..d434ecdb45 100644
--- a/submodule-config.h
+++ b/submodule-config.h
@@ -22,16 +22,17 @@ struct submodule {
int recommend_shallow;
};
-int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
-int parse_push_recurse_submodules_arg(const char *opt, const char *arg);
-int parse_submodule_config_option(const char *var, const char *value);
-const struct submodule *submodule_from_name(const unsigned char *commit_or_tree,
- const char *name);
-const struct submodule *submodule_from_path(const unsigned char *commit_or_tree,
- const char *path);
+extern int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
+extern int parse_update_recurse_submodules_arg(const char *opt, const char *arg);
+extern int parse_push_recurse_submodules_arg(const char *opt, const char *arg);
+extern int parse_submodule_config_option(const char *var, const char *value);
+extern const struct submodule *submodule_from_name(
+ const unsigned char *commit_or_tree, const char *name);
+extern const struct submodule *submodule_from_path(
+ const unsigned char *commit_or_tree, const char *path);
extern int gitmodule_sha1_from_commit(const unsigned char *commit_sha1,
unsigned char *gitmodules_sha1,
struct strbuf *rev);
-void submodule_free(void);
+extern void submodule_free(void);
#endif /* SUBMODULE_CONFIG_H */
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 06/14] update submodules: add a config option to determine if submodules are updated
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
In later patches we introduce the options and flag for commands
that modify the working directory, e.g. git-checkout.
Have a central place to store such settings whether we want to update
a submodule.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
submodule.c | 6 ++++++
submodule.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/submodule.c b/submodule.c
index 9bbdd3ce7c..c0060c29f2 100644
--- a/submodule.c
+++ b/submodule.c
@@ -17,6 +17,7 @@
#include "worktree.h"
static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
+static int config_update_recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
static int parallel_jobs = 1;
static struct string_list changed_submodule_paths = STRING_LIST_INIT_NODUP;
static int initialized_fetch_ref_tips;
@@ -545,6 +546,11 @@ void set_config_fetch_recurse_submodules(int value)
config_fetch_recurse_submodules = value;
}
+void set_config_update_recurse_submodules(int value)
+{
+ config_update_recurse_submodules = value;
+}
+
static int has_remote(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
{
diff --git a/submodule.h b/submodule.h
index 689033e538..c4e1ac828e 100644
--- a/submodule.h
+++ b/submodule.h
@@ -58,6 +58,7 @@ 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);
+extern void set_config_update_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,
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 07/14] update submodules: introduce is_interesting_submodule
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
In later patches we introduce the --recurse-submodule flag for commands
that modify the working directory, e.g. git-checkout.
It is potentially expensive to check if a submodule needs an update,
because a common theme to interact with submodules is to spawn a child
process for each interaction.
So let's introduce a function that pre checks if a submodule needs
to be checked for an update.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
submodule.c | 26 ++++++++++++++++++++++++++
submodule.h | 8 ++++++++
2 files changed, 34 insertions(+)
diff --git a/submodule.c b/submodule.c
index c0060c29f2..4c33374ae8 100644
--- a/submodule.c
+++ b/submodule.c
@@ -551,6 +551,32 @@ void set_config_update_recurse_submodules(int value)
config_update_recurse_submodules = value;
}
+int submodules_interesting_for_update(void)
+{
+ /*
+ * Update can't be "none", "merge" or "rebase",
+ * treat any value as OFF, except an explicit ON.
+ */
+ return config_update_recurse_submodules == RECURSE_SUBMODULES_ON;
+}
+
+int is_interesting_submodule(const struct cache_entry *ce)
+{
+ const struct submodule *sub;
+
+ if (!S_ISGITLINK(ce->ce_mode))
+ return 0;
+
+ if (!submodules_interesting_for_update())
+ return 0;
+
+ sub = submodule_from_path(null_sha1, ce->name);
+ if (!sub)
+ return 0;
+
+ return sub->update_strategy.type != SM_UPDATE_NONE;
+}
+
static int has_remote(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
{
diff --git a/submodule.h b/submodule.h
index c4e1ac828e..84b67a7c4a 100644
--- a/submodule.h
+++ b/submodule.h
@@ -59,6 +59,14 @@ extern void show_submodule_inline_diff(FILE *f, const char *path,
const struct diff_options *opt);
extern void set_config_fetch_recurse_submodules(int value);
extern void set_config_update_recurse_submodules(int value);
+
+/*
+ * Traditionally Git ignored changes made for submodules.
+ * This function checks if we are interested in the given submodule
+ * for any kind of operation.
+ */
+extern int submodules_interesting_for_update(void);
+extern int is_interesting_submodule(const struct cache_entry *ce);
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,
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 11/14] unpack-trees: check if we can perform the operation for submodules
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
unpack-trees.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
unpack-trees.h | 1 +
2 files changed, 90 insertions(+), 9 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 616a0ae4b2..6805cb9549 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -10,6 +10,7 @@
#include "attr.h"
#include "split-index.h"
#include "dir.h"
+#include "submodule.h"
/*
* Error messages expected by scripts out of plumbing commands such as
@@ -45,6 +46,9 @@ static const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {
/* ERROR_WOULD_LOSE_ORPHANED_REMOVED */
"Working tree file '%s' would be removed by sparse checkout update.",
+
+ /* ERROR_WOULD_LOSE_UNTRACKED_SUBMODULE */
+ "Submodule '%s' cannot be deleted as it contains untracked files.",
};
#define ERRORMSG(o,type) \
@@ -161,6 +165,8 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
_("The following working tree files would be overwritten by sparse checkout update:\n%s");
msgs[ERROR_WOULD_LOSE_ORPHANED_REMOVED] =
_("The following working tree files would be removed by sparse checkout update:\n%s");
+ msgs[ERROR_WOULD_LOSE_UNTRACKED_SUBMODULE] =
+ _("Submodule '%s' cannot be deleted as it contains untracked files.");
opts->show_all_errors = 1;
/* rejected paths may not have a static buffer */
@@ -240,12 +246,44 @@ static void display_error_msgs(struct unpack_trees_options *o)
fprintf(stderr, _("Aborting\n"));
}
+static int submodule_check_from_to(const struct cache_entry *ce, const char *old_id, const char *new_id, struct unpack_trees_options *o)
+{
+ if (submodule_go_from_to(ce->name, old_id,
+ new_id, 1, o->reset))
+ return o->gently ? -1 :
+ add_rejected_path(o, ERROR_WOULD_LOSE_UNTRACKED_SUBMODULE, ce->name);
+ return 0;
+}
+
+static void reload_gitmodules_file(struct index_state *index,
+ struct checkout *state)
+{
+ int i;
+ for (i = 0; i < index->cache_nr; i++) {
+ struct cache_entry *ce = index->cache[i];
+ if (ce->ce_flags & CE_UPDATE) {
+
+ int r = strcmp(ce->name, ".gitmodules");
+ if (r < 0)
+ continue;
+ else if (r == 0) {
+ checkout_entry(ce, state, NULL);
+ } else
+ break;
+ }
+ }
+ gitmodules_config();
+ git_config(submodule_config, NULL);
+}
+
/*
* Unlink the last component and schedule the leading directories for
* removal, such that empty directories get removed.
*/
static void unlink_entry(const struct cache_entry *ce)
{
+ if (is_interesting_submodule(ce))
+ submodule_go_from_to(ce->name, "HEAD", NULL, 0, 1);
if (!check_leading_path(ce->name, ce_namelen(ce)))
return;
if (remove_or_warn(ce->ce_mode, ce->name))
@@ -301,6 +339,9 @@ static int check_updates(struct unpack_trees_options *o)
remove_marked_cache_entries(index);
remove_scheduled_dirs();
+ if (submodules_interesting_for_update() && o->update && !o->dry_run)
+ reload_gitmodules_file(index, &state);
+
for (i = 0; i < index->cache_nr; i++) {
struct cache_entry *ce = index->cache[i];
@@ -1358,17 +1399,27 @@ static int verify_uptodate_1(const struct cache_entry *ce,
if (!lstat(ce->name, &st)) {
int flags = CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE;
unsigned changed = ie_match_stat(o->src_index, ce, &st, flags);
+
+ if (is_interesting_submodule(ce)) {
+ int r;
+ r = submodule_check_from_to(ce,
+ "HEAD", oid_to_hex(&ce->oid), o);
+ if (r)
+ return o->gently ? -1 :
+ add_rejected_path(o, error_type, ce->name);
+ return 0;
+ }
+
if (!changed)
return 0;
/*
- * NEEDSWORK: the current default policy is to allow
- * submodule to be out of sync wrt the superproject
- * index. This needs to be tightened later for
- * submodules that are marked to be automatically
- * checked out.
+ * Historic default policy was to allow submodule to be out
+ * of sync wrt the superproject index. If the submodule was
+ * not considered interesting above, we don't care here.
*/
if (S_ISGITLINK(ce->ce_mode))
return 0;
+
errno = 0;
}
if (errno == ENOENT)
@@ -1412,7 +1463,12 @@ static int verify_clean_submodule(const char *old_sha1,
enum unpack_trees_error_types error_type,
struct unpack_trees_options *o)
{
- return 0;
+ if (!is_interesting_submodule(ce))
+ return 0;
+
+ return submodule_check_from_to(ce,
+ old_sha1,
+ oid_to_hex(&ce->oid), o);
}
static int verify_clean_subdirectory(const struct cache_entry *ce,
@@ -1578,9 +1634,15 @@ static int verify_absent_1(const struct cache_entry *ce,
path = xmemdupz(ce->name, len);
if (lstat(path, &st))
ret = error_errno("cannot stat '%s'", path);
- else
- ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,
- &st, error_type, o);
+ else {
+ if (is_interesting_submodule(ce))
+ ret = submodule_check_from_to(ce,
+ oid_to_hex(&ce->oid),
+ NULL, o);
+ else
+ ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,
+ &st, error_type, o);
+ }
free(path);
return ret;
} else if (lstat(ce->name, &st)) {
@@ -1588,6 +1650,10 @@ static int verify_absent_1(const struct cache_entry *ce,
return error_errno("cannot stat '%s'", ce->name);
return 0;
} else {
+ if (is_interesting_submodule(ce))
+ return submodule_check_from_to(ce, oid_to_hex(&ce->oid),
+ NULL, o);
+
return check_ok_to_remove(ce->name, ce_namelen(ce),
ce_to_dtype(ce), ce, &st,
error_type, o);
@@ -1643,6 +1709,16 @@ static int merged_entry(const struct cache_entry *ce,
return -1;
}
invalidate_ce_path(merge, o);
+
+ if (is_interesting_submodule(ce)) {
+ int ret = submodule_check_from_to(ce,
+ oid_to_hex(&old->oid),
+ oid_to_hex(&ce->oid),
+ o);
+ if (ret)
+ return ret;
+ }
+
} else if (!(old->ce_flags & CE_CONFLICTED)) {
/*
* See if we can re-use the old CE directly?
@@ -1663,6 +1739,10 @@ static int merged_entry(const struct cache_entry *ce,
update |= old->ce_flags & (CE_SKIP_WORKTREE | CE_NEW_SKIP_WORKTREE);
invalidate_ce_path(old, o);
}
+ if (is_interesting_submodule(ce)) {
+ if (submodule_check_from_to(ce, oid_to_hex(&old->oid), oid_to_hex(&ce->oid), o))
+ return -1;
+ }
} else {
/*
* Previously unmerged entry left as an existence
diff --git a/unpack-trees.h b/unpack-trees.h
index 36a73a6d00..c0427ce082 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -21,6 +21,7 @@ enum unpack_trees_error_types {
ERROR_SPARSE_NOT_UPTODATE_FILE,
ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN,
ERROR_WOULD_LOSE_ORPHANED_REMOVED,
+ ERROR_WOULD_LOSE_UNTRACKED_SUBMODULE,
NB_UNPACK_TREES_ERROR_TYPES
};
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 10/14] unpack-trees: pass old oid to verify_clean_submodule
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
The check (which uses the old oid) is yet to be implemented, but this part
is just a refactor, so it can go separately first.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
unpack-trees.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 3a8ee19fe8..616a0ae4b2 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1407,7 +1407,8 @@ static void invalidate_ce_path(const struct cache_entry *ce,
* Currently, git does not checkout subprojects during a superproject
* checkout, so it is not going to overwrite anything.
*/
-static int verify_clean_submodule(const struct cache_entry *ce,
+static int verify_clean_submodule(const char *old_sha1,
+ const struct cache_entry *ce,
enum unpack_trees_error_types error_type,
struct unpack_trees_options *o)
{
@@ -1427,16 +1428,18 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
struct dir_struct d;
char *pathbuf;
int cnt = 0;
- unsigned char sha1[20];
- if (S_ISGITLINK(ce->ce_mode) &&
- resolve_gitlink_ref(ce->name, "HEAD", sha1) == 0) {
- /* If we are not going to update the submodule, then
+ if (S_ISGITLINK(ce->ce_mode)) {
+ unsigned char sha1[20];
+ int sub_head = resolve_gitlink_ref(ce->name, "HEAD", sha1);
+ /*
+ * If we are not going to update the submodule, then
* we don't care.
*/
- if (!hashcmp(sha1, ce->oid.hash))
+ if (!sub_head && !hashcmp(sha1, ce->oid.hash))
return 0;
- return verify_clean_submodule(ce, error_type, o);
+ return verify_clean_submodule(sub_head ? NULL : sha1_to_hex(sha1),
+ ce, error_type, o);
}
/*
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 09/14] update submodules: add submodule_go_from_to
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
In later patches we introduce the options and flag for commands
that modify the working directory, e.g. git-checkout.
This piece of code will be used universally for
all these working tree modifications as it
* supports dry run to answer the question:
"Is it safe to change the submodule to this new state?"
e.g. is it overwriting untracked files or are there local
changes that would be overwritten?
* supports a force flag that can be used for resetting
the tree.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
submodule.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
submodule.h | 5 ++
2 files changed, 156 insertions(+)
diff --git a/submodule.c b/submodule.c
index d3fc6c2a75..194cba9535 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1252,6 +1252,157 @@ int bad_to_remove_submodule(const char *path, unsigned flags)
return ret;
}
+static int submodule_has_dirty_index(const struct submodule *sub)
+{
+ ssize_t len;
+ struct child_process cp = CHILD_PROCESS_INIT;
+ struct strbuf buf = STRBUF_INIT;
+ int ret = 0;
+
+ prepare_submodule_repo_env_no_git_dir(&cp.env_array);
+
+ cp.git_cmd = 1;
+ argv_array_pushl(&cp.args, "diff-index", "--cached", "HEAD", NULL);
+ cp.no_stdin = 1;
+ cp.out = -1;
+ cp.dir = sub->path;
+ if (start_command(&cp))
+ die("could not recurse into submodule %s", sub->path);
+
+ len = strbuf_read(&buf, cp.out, 1024);
+ if (len > 2)
+ ret = 1;
+
+ close(cp.out);
+ if (finish_command(&cp))
+ die("could not recurse into submodule %s", sub->path);
+
+ strbuf_release(&buf);
+ return ret;
+}
+
+void submodule_clean_index(const char *path)
+{
+ struct child_process cp = CHILD_PROCESS_INIT;
+ prepare_submodule_repo_env_no_git_dir(&cp.env_array);
+
+ cp.git_cmd = 1;
+ cp.no_stdin = 1;
+ cp.dir = path;
+
+ argv_array_pushf(&cp.args, "--super-prefix=%s/", path);
+ argv_array_pushl(&cp.args, "read-tree", "-u", "--reset", NULL);
+
+ argv_array_push(&cp.args, EMPTY_TREE_SHA1_HEX);
+
+ if (run_command(&cp))
+ die("could not clean submodule index");
+}
+
+/**
+ * Moves a submodule at a given path from a given head to another new head.
+ * For edge cases (a submodule coming into existence or removing a submodule)
+ * pass NULL for old or new respectively.
+ *
+ * TODO: move dryrun and forced to flags.
+ */
+int submodule_go_from_to(const char *path,
+ const char *old,
+ const char *new,
+ int dry_run,
+ int force)
+{
+ int ret = 0;
+ struct child_process cp = CHILD_PROCESS_INIT;
+ const struct submodule *sub;
+
+ sub = submodule_from_path(null_sha1, path);
+
+ if (!sub)
+ die("BUG: could not get submodule information for '%s'", path);
+
+ if (!dry_run) {
+ if (old) {
+ if (!submodule_uses_gitfile(path))
+ absorb_git_dir_into_superproject("", path,
+ ABSORB_GITDIR_RECURSE_SUBMODULES);
+ } else {
+ struct strbuf sb = STRBUF_INIT;
+ strbuf_addf(&sb, "%s/modules/%s",
+ get_git_common_dir(), sub->name);
+ connect_work_tree_and_git_dir(path, sb.buf);
+ strbuf_release(&sb);
+
+ /* make sure the index is clean as well */
+ submodule_clean_index(path);
+ }
+ }
+
+ if (old && !force) {
+ /* Check if the submodule has a dirty index. */
+ if (submodule_has_dirty_index(sub)) {
+ /* print a thing here? */
+ return -1;
+ }
+ }
+
+ prepare_submodule_repo_env_no_git_dir(&cp.env_array);
+
+ cp.git_cmd = 1;
+ cp.no_stdin = 1;
+ cp.dir = path;
+
+ argv_array_pushf(&cp.args, "--super-prefix=%s/", path);
+ argv_array_pushl(&cp.args, "read-tree", NULL);
+
+ if (!dry_run)
+ argv_array_push(&cp.args, "-u");
+ else
+ argv_array_push(&cp.args, "-n");
+
+ if (force)
+ argv_array_push(&cp.args, "--reset");
+ else
+ argv_array_push(&cp.args, "-m");
+
+ argv_array_push(&cp.args, old ? old : EMPTY_TREE_SHA1_HEX);
+ argv_array_push(&cp.args, new ? new : EMPTY_TREE_SHA1_HEX);
+
+ if (run_command(&cp)) {
+ ret = -1;
+ goto out;
+ }
+
+ if (!dry_run) {
+ if (new) {
+ struct child_process cp1 = CHILD_PROCESS_INIT;
+ /* also set the HEAD accordingly */
+ cp1.git_cmd = 1;
+ cp1.no_stdin = 1;
+ cp1.dir = path;
+
+ argv_array_pushl(&cp1.args, "update-ref", "HEAD",
+ new ? new : EMPTY_TREE_SHA1_HEX, NULL);
+
+ if (run_command(&cp1)) {
+ ret = -1;
+ goto out;
+ }
+ } else {
+ struct strbuf sb = STRBUF_INIT;
+
+ strbuf_addf(&sb, "%s/.git", path);
+ unlink_or_warn(sb.buf);
+ strbuf_release(&sb);
+
+ if (is_empty_dir(path))
+ rmdir_or_warn(path);
+ }
+ }
+out:
+ return ret;
+}
+
static int find_first_merges(struct object_array *result, const char *path,
struct commit *a, struct commit *b)
{
diff --git a/submodule.h b/submodule.h
index 84b67a7c4a..570953a351 100644
--- a/submodule.h
+++ b/submodule.h
@@ -91,6 +91,11 @@ extern int push_unpushed_submodules(struct sha1_array *commits,
extern void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
extern int parallel_submodules(void);
+extern int submodule_go_from_to(const char *path,
+ const char *old,
+ const char *new,
+ int dry_run, int force);
+
/*
* Prepare the "env_array" parameter of a "struct child_process" for executing
* a submodule by clearing any repo-specific envirionment variables, but
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 04/14] connect_work_tree_and_git_dir: safely create leading directories
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
In a later patch we'll use connect_work_tree_and_git_dir when the
directory for the gitlink file doesn't exist yet. Safely create
the directory first.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
dir.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dir.c b/dir.c
index 4541f9e146..69ca3d1411 100644
--- a/dir.c
+++ b/dir.c
@@ -2735,6 +2735,8 @@ void connect_work_tree_and_git_dir(const char *work_tree_, const char *git_dir_)
/* Update gitfile */
strbuf_addf(&file_name, "%s/.git", work_tree);
+ if (safe_create_leading_directories_const(file_name.buf))
+ fprintf(stderr, "could not create directories for %s\n", file_name.buf);
write_file(file_name.buf, "gitdir: %s",
relative_path(git_dir, work_tree, &rel_path));
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 13/14] entry.c: update submodules when interesting
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
entry.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/entry.c b/entry.c
index c6eea240b6..bc6295d41a 100644
--- a/entry.c
+++ b/entry.c
@@ -2,6 +2,7 @@
#include "blob.h"
#include "dir.h"
#include "streaming.h"
+#include "submodule.h"
static void create_directories(const char *path, int path_len,
const struct checkout *state)
@@ -203,6 +204,13 @@ static int write_entry(struct cache_entry *ce,
return error("cannot create temporary submodule %s", path);
if (mkdir(path, 0777) < 0)
return error("cannot create submodule directory %s", path);
+ if (is_interesting_submodule(ce))
+ /*
+ * force=1 is ok for any case as we did a dry
+ * run before with appropriate force setting
+ */
+ return submodule_go_from_to(ce->name,
+ NULL, oid_to_hex(&ce->oid), 0, 1);
break;
default:
return error("unknown file mode for %s in index", path);
@@ -260,6 +268,26 @@ int checkout_entry(struct cache_entry *ce,
if (!check_path(path.buf, path.len, &st, state->base_dir_len)) {
unsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
+ /*
+ * Needs to be checked before !changed returns early,
+ * as the possibly empty directory was not changed
+ */
+ if (is_interesting_submodule(ce)) {
+ int err;
+ if (!is_submodule_populated_gently(ce->name, &err)) {
+ struct stat sb;
+ if (lstat(ce->name, &sb))
+ die(_("could not stat file '%s'"), ce->name);
+ if (!(st.st_mode & S_IFDIR))
+ unlink_or_warn(ce->name);
+
+ return submodule_go_from_to(ce->name,
+ NULL, oid_to_hex(&ce->oid), 0, 1);
+ } else
+ return submodule_go_from_to(ce->name,
+ "HEAD", oid_to_hex(&ce->oid), 0, 1);
+ }
+
if (!changed)
return 0;
if (!state->force) {
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 14/14] builtin/checkout: add --recurse-submodules switch
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
Documentation/git-checkout.txt | 7 +++++++
builtin/checkout.c | 28 ++++++++++++++++++++++++++++
t/lib-submodule-update.sh | 33 ++++++++++++++++++++++++---------
t/t2013-checkout-submodule.sh | 5 +++++
4 files changed, 64 insertions(+), 9 deletions(-)
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 8e2c0662dd..a0ea2c5651 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -256,6 +256,13 @@ section of linkgit:git-add[1] to learn how to operate the `--patch` mode.
out anyway. In other words, the ref can be held by more than one
worktree.
+--[no-]recurse-submodules::
+ Using --recurse-submodules will update the content of all initialized
+ submodules according to the commit recorded in the superproject. If
+ local modifications in a submodule would be overwritten the checkout
+ will fail until `-f` is used. If nothing (or --no-recurse-submodules)
+ is used, the work trees of submodules will not be updated.
+
<branch>::
Branch to checkout; if it refers to a branch (i.e., a name that,
when prepended with "refs/heads/", is a valid ref), then that
diff --git a/builtin/checkout.c b/builtin/checkout.c
index f174f50303..207ce09771 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -21,12 +21,31 @@
#include "submodule-config.h"
#include "submodule.h"
+static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
+
static const char * const checkout_usage[] = {
N_("git checkout [<options>] <branch>"),
N_("git checkout [<options>] [<branch>] -- <file>..."),
NULL,
};
+int option_parse_recurse_submodules(const struct option *opt,
+ const char *arg, int unset)
+{
+ if (unset) {
+ recurse_submodules = RECURSE_SUBMODULES_OFF;
+ return 0;
+ }
+ if (arg)
+ recurse_submodules =
+ parse_update_recurse_submodules_arg(opt->long_name,
+ arg);
+ else
+ recurse_submodules = RECURSE_SUBMODULES_ON;
+
+ return 0;
+}
+
struct checkout_opts {
int patch_mode;
int quiet;
@@ -1163,6 +1182,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
N_("second guess 'git checkout <no-such-branch>'")),
OPT_BOOL(0, "ignore-other-worktrees", &opts.ignore_other_worktrees,
N_("do not check if another worktree is holding the given ref")),
+ { OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules,
+ "checkout", "control recursive updating of submodules",
+ PARSE_OPT_OPTARG, option_parse_recurse_submodules },
OPT_BOOL(0, "progress", &opts.show_progress, N_("force progress reporting")),
OPT_END(),
};
@@ -1193,6 +1215,12 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
git_xmerge_config("merge.conflictstyle", conflict_style, NULL);
}
+ if (recurse_submodules != RECURSE_SUBMODULES_OFF) {
+ git_config(submodule_config, NULL);
+ if (recurse_submodules != RECURSE_SUBMODULES_DEFAULT)
+ set_config_update_recurse_submodules(recurse_submodules);
+ }
+
if ((!!opts.new_branch + !!opts.new_branch_force + !!opts.new_orphan_branch) > 1)
die(_("-b, -B and --orphan are mutually exclusive"));
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index 7c8c557572..9c75a417d4 100755
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -734,6 +734,11 @@ test_submodule_forced_switch () {
test_submodule_switch_recursing () {
command="$1"
+ RESULT=success
+ if test "$KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS" = 1
+ then
+ RESULT=failure
+ fi
######################### Appearing submodule #########################
# Switching to a commit letting a submodule appear checks it out ...
test_expect_success "$command: added submodule is checked out" '
@@ -843,7 +848,7 @@ test_submodule_switch_recursing () {
'
# Replacing a submodule with files in a directory must succeeds
# when the submodule is clean
- test_expect_success "$command: replace submodule with a directory" '
+ test_expect_$RESULT "$command: replace submodule with a directory" '
prolog &&
reset_work_tree_to_interested add_sub1 &&
(
@@ -855,7 +860,7 @@ test_submodule_switch_recursing () {
)
'
# ... absorbing a .git directory.
- test_expect_success "$command: replace submodule containing a .git directory with a directory must absorb the git dir" '
+ test_expect_$RESULT "$command: replace submodule containing a .git directory with a directory must absorb the git dir" '
prolog &&
reset_work_tree_to_interested add_sub1 &&
(
@@ -883,7 +888,7 @@ test_submodule_switch_recursing () {
'
# ... must check its local work tree for untracked files
- test_expect_success "$command: replace submodule with a file must fail with untracked files" '
+ test_expect_$RESULT "$command: replace submodule with a file must fail with untracked files" '
prolog &&
reset_work_tree_to_interested add_sub1 &&
(
@@ -939,16 +944,21 @@ test_submodule_switch_recursing () {
)
'
+ # This test fails, due to missing setup, we do not clone sub2 into
+ # submodule_update, because it doesn't exist in the 'add_sub1' version
+ #
test_expect_success "$command: modified submodule updates submodule recursively" '
prolog &&
reset_work_tree_to_interested add_sub1 &&
(
cd submodule_update &&
git branch -t modify_sub1_recursively origin/modify_sub1_recursively &&
- $command modify_sub1_recursively &&
- test_superproject_content origin/modify_sub1_recursively &&
- test_submodule_content sub1 origin/modify_sub1_recursively
- test_submodule_content sub1/sub2
+ test_must_fail $command modify_sub1_recursively &&
+ test_superproject_content origin/add_sub1 &&
+ test_submodule_content sub1 origin/add_sub1
+ # test_superproject_content origin/modify_sub1_recursively &&
+ # test_submodule_content sub1 origin/modify_sub1_recursively &&
+ # test_submodule_content sub1/sub2 no_submodule
)
'
}
@@ -958,6 +968,11 @@ test_submodule_switch_recursing () {
# the superproject as well as the submodule is allowed.
test_submodule_forced_switch_recursing () {
command="$1"
+ RESULT=success
+ if test "$KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS" = 1
+ then
+ RESULT=failure
+ fi
######################### Appearing submodule #########################
# Switching to a commit letting a submodule appear creates empty dir ...
test_expect_success "$command: added submodule is checked out" '
@@ -1052,7 +1067,7 @@ test_submodule_forced_switch_recursing () {
)
'
# Replacing a submodule with files in a directory ...
- test_expect_success "$command: replace submodule with a directory" '
+ test_expect_$RESULT "$command: replace submodule with a directory" '
prolog &&
reset_work_tree_to_interested add_sub1 &&
(
@@ -1103,7 +1118,7 @@ test_submodule_forced_switch_recursing () {
'
# ... but stops for untracked files that would be lost
- test_expect_success "$command: replace submodule with a file" '
+ test_expect_$RESULT "$command: replace submodule with a file stops for untracked files" '
prolog &&
reset_work_tree_to_interested add_sub1 &&
(
diff --git a/t/t2013-checkout-submodule.sh b/t/t2013-checkout-submodule.sh
index 6847f75822..aa35223369 100755
--- a/t/t2013-checkout-submodule.sh
+++ b/t/t2013-checkout-submodule.sh
@@ -63,6 +63,11 @@ test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/
! test -s actual
'
+KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
+test_submodule_switch_recursing "git checkout --recurse-submodules"
+
+test_submodule_forced_switch_recursing "git checkout -f --recurse-submodules"
+
test_submodule_switch "git checkout"
test_submodule_forced_switch "git checkout -f"
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 12/14] read-cache: remove_marked_cache_entries to wipe selected submodules.
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
read-cache.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/read-cache.c b/read-cache.c
index 9054369dd0..c0776b93b0 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -18,6 +18,7 @@
#include "varint.h"
#include "split-index.h"
#include "utf8.h"
+#include "submodule.h"
/* Mask for the name length in ce_flags in the on-disk index */
@@ -532,6 +533,8 @@ void remove_marked_cache_entries(struct index_state *istate)
for (i = j = 0; i < istate->cache_nr; i++) {
if (ce_array[i]->ce_flags & CE_REMOVE) {
+ if (is_interesting_submodule(ce_array[i]))
+ submodule_go_from_to(ce_array[i]->name, "HEAD", NULL, 0, 1);
remove_name_hash(istate, ce_array[i]);
save_or_free_index_entry(istate, ce_array[i]);
}
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 03/14] make is_submodule_populated gently
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
We need the gentle version in a later patch. As we have just one caller,
migrate the caller.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
builtin/grep.c | 2 +-
submodule.c | 4 ++--
submodule.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/grep.c b/builtin/grep.c
index 2c727ef499..b17835aed6 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -616,7 +616,7 @@ static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,
{
if (!is_submodule_initialized(path))
return 0;
- if (!is_submodule_populated(path)) {
+ if (!is_submodule_populated_gently(path, NULL)) {
/*
* If searching history, check for the presense of the
* submodule's gitdir before skipping the submodule.
diff --git a/submodule.c b/submodule.c
index 3b98766a6b..9bbdd3ce7c 100644
--- a/submodule.c
+++ b/submodule.c
@@ -237,12 +237,12 @@ int is_submodule_initialized(const char *path)
/*
* Determine if a submodule has been populated at a given 'path'
*/
-int is_submodule_populated(const char *path)
+int is_submodule_populated_gently(const char *path, int *return_error_code)
{
int ret = 0;
char *gitdir = xstrfmt("%s/.git", path);
- if (resolve_gitdir(gitdir))
+ if (resolve_gitdir_gently(gitdir, return_error_code))
ret = 1;
free(gitdir);
diff --git a/submodule.h b/submodule.h
index 05ab674f06..689033e538 100644
--- a/submodule.h
+++ b/submodule.h
@@ -41,7 +41,7 @@ extern int submodule_config(const char *var, const char *value, void *cb);
extern void gitmodules_config(void);
extern void gitmodules_config_sha1(const unsigned char *commit_sha1);
extern int is_submodule_initialized(const char *path);
-extern int is_submodule_populated(const char *path);
+extern int is_submodule_populated_gently(const char *path, int *return_error_code);
extern int parse_submodule_update_strategy(const char *value,
struct submodule_update_strategy *dst);
extern const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* [PATCH 08/14] update submodules: move up prepare_submodule_repo_env
From: Stefan Beller @ 2017-02-15 0:34 UTC (permalink / raw)
Cc: git, bmwill, jrnieder, sandals, gitster, Stefan Beller
In-Reply-To: <20170215003423.20245-1-sbeller@google.com>
In a later patch we need to prepare the submodule environment with
another git directory, so split up the function.
Also move it up in the file such that we do not need to declare the
function later before using it.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
submodule.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/submodule.c b/submodule.c
index 4c33374ae8..d3fc6c2a75 100644
--- a/submodule.c
+++ b/submodule.c
@@ -359,6 +359,23 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
strbuf_release(&sb);
}
+static void prepare_submodule_repo_env_no_git_dir(struct argv_array *out)
+{
+ const char * const *var;
+
+ for (var = local_repo_env; *var; var++) {
+ if (strcmp(*var, CONFIG_DATA_ENVIRONMENT))
+ argv_array_push(out, *var);
+ }
+}
+
+void prepare_submodule_repo_env(struct argv_array *out)
+{
+ prepare_submodule_repo_env_no_git_dir(out);
+ argv_array_pushf(out, "%s=%s", GIT_DIR_ENVIRONMENT,
+ DEFAULT_GIT_DIR_ENVIRONMENT);
+}
+
/* 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
@@ -1403,18 +1420,6 @@ int parallel_submodules(void)
return parallel_jobs;
}
-void prepare_submodule_repo_env(struct argv_array *out)
-{
- const char * const *var;
-
- for (var = local_repo_env; *var; var++) {
- if (strcmp(*var, CONFIG_DATA_ENVIRONMENT))
- argv_array_push(out, *var);
- }
- argv_array_pushf(out, "%s=%s", GIT_DIR_ENVIRONMENT,
- DEFAULT_GIT_DIR_ENVIRONMENT);
-}
-
/*
* Embeds a single submodules git directory into the superprojects git dir,
* non recursively.
--
2.12.0.rc0.16.gd1691994b4.dirty
^ permalink raw reply related
* Re: [PATCH 11/11] refs: split and make get_*_ref_store() public API
From: Duy Nguyen @ 2017-02-15 0:44 UTC (permalink / raw)
To: Junio C Hamano
Cc: Stefan Beller, git@vger.kernel.org, Michael Haggerty,
Johannes Schindelin, David Turner
In-Reply-To: <xmqq8tp8aawb.fsf@gitster.mtv.corp.google.com>
On Wed, Feb 15, 2017 at 1:24 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Duy Nguyen <pclouds@gmail.com> writes:
>
>> Direct call sites are just middle men though, e.g.
>> for_each_ref_submodule(). I'll attempt to clean this up at some point
>> in future (probably at the same time I attempt to kill *_submodule ref
>> api). But I think for now I'll just put a TODO or FIXME comment here.
>
> So we'd have get_*_ref_store() for various cases and then will have
> a unifying for_each_ref_in_refstore() that takes a ref-store, which
> supersedes all the ad-hoc iterators like for_each_ref_submodule(),
> for_each_namespaced_ref(), etc?
>
> That's a very sensible longer-term goal, methinks.
Ah I forgot about ref namespace. I'll need to try something out in that area.
> I am wondering what we should do to for_each_{tag,branch,...}_ref().
> Would that become
>
> ref_store = get_ref_main_store();
> tag_ref_store = filter_ref_store(ref_store, "refs/tags/");
> for_each_ref_in_refstore(tag_ref_store, ...);
>
> or do you plan to have some other pattern?
Long term, I think that's what Mike wants. Though the filter_ref_store
might return an (opaque) iterator instead of a ref store and
for_each_refstore() becomes a thin wrapper around the iterator
interface.
--
Duy
^ permalink raw reply
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