Skip to contentSkip to conversation

What's cooking in git.git (Apr 2010, #01; Fri, 02)

DISCUSSION Junio C Hamano 5 participants 8 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Here are the topics that have been cooking. Commits prefixed with '-' are only in 'pu' 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.

Topics not in 'next' will have to wait until post 1.7.1 cycle. I expect that the changes already under discussion will be ready by the time the post 1.7.1 cycle begins, and we will hopefully have a cycle for 1.7.2 that is shorter than usual to include them.

--------------------------------------------------
[Graduated to "master"]

* sb/notes-parse-opt (2010-02-27) 1 commit
(merged to 'next' on 2010-03-24 at 82eebc1)
+ notes: rework subcommands and parse options

* cc/cherry-pick-ff (2010-03-20) 7 commits
(merged to 'next' on 2010-03-20 at a1ae16b)
+ revert: fix tiny memory leak in cherry-pick --ff
+ rebase -i: use new --ff cherry-pick option
(merged to 'next' on 2010-03-07 at 5589b26)
+ Documentation: describe new cherry-pick --ff option
+ cherry-pick: add tests for new --ff option
+ revert: add --ff option to allow fast forward when cherry-picking
+ builtin/merge: make checkout_fast_forward() non static
+ parse-options: add parse_options_concat() to concat options

--------------------------------------------------
[New Topics]

* cw/ws-indent-with-tab (2010-04-01) 2 commits
- whitespace: we cannot "catch all errors known to git" anymore
- Add tab-in-indent whitespace error class

Not quite ready until "apply --whitespace=fix" gets a matching change.

* ic/bash-completion-rpm (2010-03-26) 1 commit
- RPM spec: include bash completion support

This is needed in 'master' by -rc1 at the latest. Soon in 'next'.

* js/grep-open (2010-03-26) 2 commits
- grep -O: allow optional argument specifying the pager (or editor)
- grep: Add the option '--open-files-in-pager'

Probably needs to support --no-index mode as well.

* mg/notes-reflog (2010-03-29) 2 commits
- refs.c: Write reflogs for notes just like for branch heads
- t3301-notes: Test the creation of reflog entries

Implementation is trivially correct; I am unsure if "notes" tree wants reflog in the first place, though. Please convince me and I'll move it to 'next' soon, aiming for -rc0 or -rc1 at the latest.

* rr/remote-helper-doc (2010-03-28) 2 commits
- Documentation/remote-helpers: Fix some typos
- Documentation/remote-helpers: Rewrite description

Although I lost track of this series with too rapid succession of updates, intermixed with some documentation updates in the related areas, my impression is that area experts haven't Acked them yet.

* sr/remote-helper-export (2010-03-29) 7 commits
- remote-helpers: add tests for testgit helper
- remote-helpers: add testgit helper
- remote-helpers: add support for an export command
- remote-helpers: allow requesing the path to the .git directory
- fast-import: always create marks_file directories
- clone: also configure url for bare clones
- clone: pass the remote name to remote_get

May merge to 'next', but I would prefer waiting til 1.7.2 to have this with a confidence than fast-tracking it.

* cc/revert-strategy (2010-03-31) 5 commits
- revert: add "--strategy" option to choose merge strategy
- merge: make function try_merge_command non static
- merge: refactor code that calls "git merge-STRATEGY"
- revert: refactor merge recursive code into its own function
- revert: use strbuf to refactor the code that writes the merge message (this branch uses jn/merge-diff3-label.)

May merge to 'next' soon, but this is more about debugging and we are not in a great hurry.

* mr/gitweb-jsmin (2010-04-01) 6 commits
- gitweb: update INSTALL to use shorter make target
- gitweb: add documentation to INSTALL regarding gitweb.js
- instaweb: add minification awareness
- Gitweb: add autoconfigure support for minifiers
- Gitweb: add support for minifying gitweb.css
- Gitweb: add ignore and clean rules for minified files

Soon in 'next' when minor rewording replacement patches come; otherwise felt solid.

* sc/http-late-auth (2010-04-01) 1 commit
- Prompt for a username when an HTTP request 401s

May merge to 'next', but I would prefer waiting til 1.7.2 to have this with a confidence than fast-tracking it.

* hg/convert (2010-03-29) 5 commits
. convert: Added core.refilteronadd feature.
. convert: Inhibit contraction of foreign $Id$ during stats. . convert: Use the enum constant SAFE_CRLF_FALSE. . convert: Keep foreign $Id$ on checkout.
. convert: Safer handling of $Id$ contraction.

* jk/cached-textconv (2010-04-01) 7 commits
- diff: avoid useless filespec population
- diff: cache textconv output
- textconv: refactor calls to run_textconv
- introduce notes-cache interface
- make commit_tree a library function
- fix textconv leak in emit_rewrite_diff
- fix const-correctness of write_sha1_file

May merge to 'next', but I would prefer waiting til 1.7.2 to have this with a confidence than fast-tracking it.

--------------------------------------------------
[Stalled]

* cw/test-lib-relicense (2010-02-22) 1 commit
. test-lib.sh: Add explicit license detail, with change from GPLv2 to GPLv2+.

Ack-collection stopped at the last three names. I am hoping Carl can take it from there without my keeping an eye on it.

* js/rebase-origin-x (2010-02-05) 1 commit
- [RFC w/o test and incomplete] rebase: add -x option to record original commit name

I retract my objection against the idea of -x; needs polishing before moving forward.

* sg/bash-completion (2010-02-23) 4 commits
(merged to 'next' on 2010-03-08 at bc59860)
+ bash: completion for gitk aliases
+ bash: support user-supplied completion scripts for aliases
+ bash: support user-supplied completion scripts for user's git commands
+ bash: improve aliased command recognition

Perhaps rename _git_frotz -> _git_complete_frotz? I dunno.

* sd/log-decorate (2010-02-17) 3 commits
(merged to 'next' on 2010-03-08 at 58a6fba)
+ log.decorate: usability fixes
+ Add `log.decorate' configuration variable.
+ git_config_maybe_bool()

Needs squelching the configuration setting when "--pretty=raw" is given, at least, or possibly when any "--pretty" is explicitly given.

* np/malloc-threading (2010-03-24) 1 commit
- Make xmalloc and xrealloc thread-safe

Still has locking issues?

* js/async-thread (2010-03-09) 7 commits
- Enable threaded async procedures whenever pthreads is available (merged to 'next' on 2010-03-20 at 9939243)
+ Dying in an async procedure should only exit the thread, not the process.
+ Reimplement async procedures using pthreads
+ Windows: more pthreads functions
+ Fix signature of fcntl() compatibility dummy
+ Make report() from usage.c public as vreportf() and use it.
+ Modernize t5530-upload-pack-error.

Waiting for resolution of locking issues in malloc-threading.

--------------------------------------------------
[Cooking]

* da/maint-python-startup (2010-03-27) 1 commit (merged to 'next' on 2010-04-01 at ca6897a)
+ Makefile: Remove usage of deprecated Python "has_key" method

Hopefully will merge to 'master' by -rc0.

* jc/conflict-marker-size (2010-03-24) 1 commit (merged to 'next' on 2010-04-01 at 164b1f4)
+ diff --check: honor conflict-marker-size attribute

Hopefully will merge to 'master' by -rc0.

* ld/discovery-limit-to-fs (2010-03-17) 3 commits
- Add support for GIT_ONE_FILESYSTEM
- truncate cwd string before printing error message
- config.c: remove static keyword from git_env_bool()

Linus made a good point of making this a default, and Erick Mattos confirmed that it won't be a problem even on Windows.

Will move to 'next' after such a "default on" change, keep it there until 1.7.1 ships, warn about it in the release notes as an upcoming backward incompatibility, and then move to 'master' after 1.7.1.

* sb/fmt-merge-msg (2010-03-24) 7 commits
(merged to 'next' on 2010-04-01 at 5fcbec5)
+ fmt-merge-msg: hide summary option
+ fmt-merge-msg: remove custom string_list implementation
+ string-list: add unsorted_string_list_lookup()
+ fmt-merge-msg: use pretty.c routines
+ t6200: test fmt-merge-msg more
+ t6200: modernize with test_tick
+ fmt-merge-msg: be quiet if nothing to merge

Hopefully will merge to 'master' by -rc0.

* pc/remove-warn (2010-03-26) 4 commits
- Remove a redundant errno test in a usage of remove_path
- Introduce remove_or_warn function
- Implement the rmdir_or_warn function
- Generalise the unlink_or_warn function

I cherry-picked only obviously sensible bits. Soon in 'next'.

* ef/maint-empty-commit-log (2010-03-21) 1 commit (merged to 'next' on 2010-03-28 at aa103e5)
+ rev-list: fix --pretty=oneline with empty message

Hopefully will merge to 'master' by -rc0.

* em/checkout-orphan (2010-03-21) 1 commit (merged to 'next' on 2010-03-28 at 86b6a4f)
+ git checkout: create unparented branch by --orphan

Perhaps needs a bit of documentation updates, describing the "going open source" scenario.

* mg/mailmap-update (2010-03-19) 1 commit
(merged to 'next' on 2010-03-28 at 8ac3436)
+ .mailmap: Entries for Alex Bennée, Deskin Miller, Vitaly "_Vi" Shukela

Soon in 'master'.

* mg/maint-send-email-lazy-editor (2010-03-22) 1 commit (merged to 'next' on 2010-03-28 at 7e8e58e)
+ send-email: lazily assign editor variable

Soon in 'master'.

* mg/use-default-abbrev-length-in-rev-list (2010-03-22) 1 commit (merged to 'next' on 2010-03-28 at d3e9f04)
+ rev-list: use default abbrev length when abbrev-commit is in effect

Soon in 'master'.

* rb/maint-python-path (2010-03-21) 1 commit
(merged to 'next' on 2010-03-28 at 58ba409)
+ Correct references to /usr/bin/python which does not exist on FreeBSD

Soon in 'master'.

* rr/imap-send-unconfuse-from-line (2010-03-22) 1 commit (merged to 'next' on 2010-03-28 at fbedd77)
+ imap-send: Remove limitation on message body

Soon in 'master'.

* sp/maint-http-backend-die-triggers-die-recursively (2010-03-22) 1 commit (merged to 'next' on 2010-03-28 at bf02879)
+ http-backend: Don't infinite loop during die()

Soon in 'master'.

* ar/config-from-command-line (2010-03-26) 2 commits
- Use strbufs instead of open-coded string manipulation
- Allow passing of configuration parameters in the command line

May merge to 'next', but I would prefer waiting til 1.7.2 to have this with a confidence than fast-tracking it.

* bc/t5505-fix (2010-03-19) 3 commits
(merged to 'next' on 2010-03-28 at 1b097af)
+ t/t5505-remote.sh: escape * to prevent interpretation by shell as glob
+ t5505: add missing &&
+ t5505: remove unnecessary subshell invocations

Soon in 'master'.

* bw/template-tool-buildconfig (2010-03-20) 2 commits (merged to 'next' on 2010-03-28 at 1e6fd8d)
+ Modernize git calling conventions in hook templates
+ Make templates honour SHELL_PATH and PERL_PATH

Soon in 'master'.

* mb/rebase-i-no-ff (2010-03-24) 1 commit
(merged to 'next' on 2010-03-28 at b2c54cb)
+ Teach rebase the --no-ff option.

Soon in 'master'.

* jn/merge-diff3-label (2010-03-20) 14 commits
(merged to 'next' on 2010-03-20 at 26f1805)
+ merge-recursive: add a label for ancestor
+ cherry-pick, revert: add a label for ancestor
+ revert: clarify label on conflict hunks
+ compat: add mempcpy()
+ checkout -m --conflict=diff3: add a label for ancestor
+ merge_trees(): add ancestor label parameter for diff3-style output
+ merge_file(): add comment explaining behavior wrt conflict style
+ checkout --conflict=diff3: add a label for ancestor
+ ll_merge(): add ancestor label parameter for diff3-style output
+ merge-file --diff3: add a label for ancestor
+ xdl_merge(): move file1 and file2 labels to xmparam structure
+ xdl_merge(): add optional ancestor label to diff3-style output
+ tests: document cherry-pick behavior in face of conflicts
+ tests: document format of conflicts from checkout -m (this branch is used by cc/revert-strategy.)

Soon in 'master'.

* do/rebase-i-arbitrary (2010-03-14) 1 commit
(merged to 'next' on 2010-03-28 at 5ba9970)
+ rebase--interactive: don't require what's rebased to be a branch

Soon in 'master'.

* ja/send-email-ehlo (2010-03-14) 3 commits
(merged to 'next' on 2010-03-28 at 00964a8)
+ git-send-email.perl - try to give real name of the calling host to HELO/EHLO
+ git-send-email.perl: add option --smtp-debug
+ git-send-email.perl: improve error message in send_message()

Soon in 'master'.

* ak/everyday-git (2009-10-21) 1 commit (merged to 'next' on 2010-03-28 at ae67548)
+ everyday: fsck and gc are not everyday operations

Soon in 'master'.

* bc/acl-test (2010-03-15) 5 commits
(merged to 'next' on 2010-03-28 at b40fa09)
+ t/t1304: make a second colon optional in the mask ACL check
+ t/t1304: set the ACL effective rights mask
+ t/t1304: use 'test -r' to test readability rather than looking at mode bits
+ t/t1304: set the Default ACL base entries
+ t/t1304: avoid -d option to setfacl

Soon in 'master'.

* bc/maint-daemon-sans-ss-family (2010-03-15) 1 commit (merged to 'next' on 2010-03-28 at 305ad0b)
+ daemon.c: avoid accessing ss_family member of struct sockaddr_storage

Soon in 'master'.

* ef/cherry-abbrev (2010-03-20) 2 commits
(merged to 'next' on 2010-03-28 at eb3825c)
+ ls: remove redundant logic
+ cherry: support --abbrev option

Soon in 'master'.

* gh/maint-stash-show-error-message (2010-03-16) 1 commit (merged to 'next' on 2010-03-28 at 61a5643)
+ Improve error messages from 'git stash show'

Soon in 'master'.

* rs/threaded-grep-context (2010-03-15) 1 commit (merged to 'next' on 2010-03-28 at 1934af1)
+ grep: enable threading for context line printing

Soon in 'master'.

* nd/setup (2010-03-25) 43 commits
- builtins: do not commit pager choice early
- builtins: reset startup_info->have_run_setup_gitdir when unsetting up repository
- builtins: setup repository before print unknown command error
- Guard unallowed access to repository when it's not set up
- alias: keep repository found while collecting aliases as long as possible
- Allow to undo setup_git_directory_gently() gracefully (and fix alias code)
- builtins: check for startup_info->help, print and exit early
- builtins: utilize startup_info->help where possible
- run_builtin(): save "-h" detection result for later use
- config: do not read .git/config if there is no repository
- apply: do not check sha1 when repository has not been found
- Do not read .git/info/attributes if there is no repository
- Do not read .git/info/exclude if there is no repository
- git_config(): do not read .git/config if there is no repository
- init/clone: turn on startup->have_repository properly
- worktree setup: restore original state when things go wrong
- Use git_config_early() instead of git_config() during repo setup
- Add git_config_early()
- worktree setup: call set_git_dir explicitly
- rev-parse --git-dir: print relative gitdir correctly
- enter_repo(): initialize other variables as setup_git_directory_gently() does
- Move enter_repo() to setup.c
- index-pack: use RUN_SETUP_GENTLY
- index-pack: trust the prefix returned by setup_git_directory_gently()
- worktree setup: calculate prefix even if no worktree is found
- merge-file: use RUN_SETUP_GENTLY
- var: use RUN_SETUP_GENTLY
- ls-remote: use RUN_SETUP_GENTLY
- help: use RUN_SETUP_GENTLY
- diff: use RUN_SETUP_GENTLY
- bundle: use RUN_SETUP_GENTLY
- apply: use RUN_SETUP_GENTLY
- verify-pack: use RUN_SETUP_GENTLY
- check-ref-format: use RUN_SETUP_GENTLY
- mailinfo: use RUN_SETUP_GENTLY
- archive: use RUN_SETUP_GENTLY
- builtin: USE_PAGER should not be used without RUN_SETUP*
- grep: use RUN_SETUP_GENTLY
- shortlog: use RUN_SETUP_GENTLY
- hash-object: use RUN_SETUP_GENTLY
- config: use RUN_SETUP_GENTLY
- builtin: Support RUN_SETUP_GENTLY to set up repository early if found
- builtin: introduce startup_info struct

#1 lore raw
Quoted 4 lines · Junio C Hamano

* nd/setup (2010-03-25) 43 commits
 - builtins: do not commit pager choice early
...
 - builtin: introduce startup_info struct

I haven't forgotten the "git init" with alias bug Jonathan found. Just a little busy with other stuff.

Signature · 1 line
Duy
#2 lore raw

nd/setup

Quoted 2 lines · Nguyen Thai Ngoc Duy

I haven't forgotten the "git init" with alias bug Jonathan found. Just a little busy with other stuff.

You already fixed it, I think. ;-)

Unfortunately, I have also run into a double-initialization bug with clone. I haven’t figured out how to reproduce it yet; once I do, I’ll send a patch.

Overall, I think this series does a good thing, so I am anxious to find all the bugs I can so the wrinkles get ironed out.

Here’s another tiny issue.

-- %< --
Subject: Revert "help: use RUN_SETUP_GENTLY"

Commit 717b8850580ecb9009505f71ea43ecda51ac1f0e taught ‘git help’ to unconditionally looks for a git directory, with the justification:

So the sooner we set up gitdir, the less trouble we may have to deal with.

In the case of ‘git help -a’, that is not quite true. In automount setups like that which prompted v1.6.0-rc0~121^2~1 (Add support for GIT_CEILING_DIRECTORIES, 2008-05-19), if GIT_CEILING_DIRECTORIES is unset, then probing for the Git directory can take a long time. Thus unnecessarily searching for a git directory can slow down ‘git help -a’ (and thus bash completion).

‘git help’ does not use RUN_SETUP or USE_PAGER, and neither option parsing nor producing output for plain ‘git help’ or ‘git help -a’ requires access to the git configuration. Therefore it is safe to not search for the git directory early in this case.

Also add some comments to document the requirements this places on list_commands() and list_common_cmds_help().

---
 builtin/help.c |    7 +++++++
 git.c          |    2 +-
 help.c         |    4 ++++
 3 files changed, 12 insertions(+), 1 deletions(-)
builtin/help.c +7 -0
index 4988629..68b72df 100644
@@ -271,6 +271,11 @@ static int git_help_config(const char *var, const char *value, void *cb)
 
 static struct cmdnames main_cmds, other_cmds;
 
+/*
+ * Used for plain ‘git’ and ‘git help’.
+ * Therefore this should not use git_config(), nor any other function
+ * that requires searching for a repository.
+ */
 void list_common_cmds_help(void)
 {
 	int i, longest = 0;
@@ -414,6 +419,7 @@ static void show_html_page(const char *git_cmd)
 
 int cmd_help(int argc, const char **argv, const char *prefix)
 {
+	int unused_nongit;
 	const char *alias;
 	enum help_format parsed_help_format;
 	load_command_list("git-", &main_cmds, &other_cmds);
@@ -436,6 +442,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
 		return 0;
 	}
 
+	setup_git_directory_gently(&unused_nongit);
 	git_config(git_help_config, NULL);
 
 	if (parsed_help_format != HELP_FORMAT_NONE)
git.c +1 -1
index 5c249fd..0125152 100644
@@ -335,7 +335,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "get-tar-commit-id", cmd_get_tar_commit_id },
 		{ "grep", cmd_grep, RUN_SETUP_GENTLY | USE_PAGER },
 		{ "hash-object", cmd_hash_object, RUN_SETUP_GENTLY },
-		{ "help", cmd_help, RUN_SETUP_GENTLY },
+		{ "help", cmd_help },
 		{ "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
 		{ "init", cmd_init_db },
 		{ "init-db", cmd_init_db },
help.c +4 -0
index 7f4928e..f68ef43 100644
@@ -221,6 +221,10 @@ void load_command_list(const char *prefix,
 	exclude_cmds(other_cmds, main_cmds);
 }
 
+/*
+ * Used for ‘git help -a’.  Therefore this should not use git_config(),
+ * nor any other function that requires searching for a repository.
+ */
 void list_commands(const char *title, struct cmdnames *main_cmds,
 		   struct cmdnames *other_cmds)
 {
Signature · 1 line
1.7.0.3
#3 lore raw

Re: nd/setup

Junio,

I wanted to update nd/setup topic, but found nd/root-git was merged in between its two parts, which resulted in non-trivial conflicts in the end. Changes are minor, mainly to clean up the topic. So it's up to you to either leave the topic as is (plus Jonathan's "help revert" patch on top) or replace with some patches I attach, because if I send the whole topic again, you would need to resolve conflicts manually. I'll make proper patch messages next time once I figure out how to send conflict resolutions through mail.

- 717b885 help: use RUN_SETUP_GENTLY
replaced by 0001 (needs to resolve conflict in the next patch in
topic, but it's quite simple)
- 450476a worktree setup: restore original state when things go wrong replaced by 0002
- bc7cd1c Guard unallowed access to repository when it's not set up replaced by 0003 and 0004
- a55fdda builtins: reset startup_info->have_run_setup_gitdir when unsetting up repository
dropped (splitted as part of 0002-0004)
--
Duy

From 4c5d6bc49e262d3331069dd7d8fb8fc6785f5d4b Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <[email protected]>
Date: Sun, 4 Apr 2010 17:49:38 +0200
Subject: [PATCH] help: take note why this command is not applicable for RUN_SETUP_GENTLY
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

"git help" calls setup_git_directory_gently(), thus a candidate for RUN_SETUP_GENTLY. However RUN_SETUP_GENTLY should not be used for performance reason, as follows.

In automount setups like that which prompted v1.6.0-rc0~121^2~1 (Add support for GIT_CEILING_DIRECTORIES, 2008-05-19), if GIT_CEILING_DIRECTORIES is unset, then probing for the Git directory can take a long time. Thus unnecessarily searching for a git directory can slow down 'git help -a' (and thus bash completion).

'git help' does not use RUN_SETUP or USE_PAGER, and neither option parsing nor producing output for plain 'git help' or 'git help -a' requires access to the git configuration. Therefore it is safe to not search for the git directory early in this case.

Also add some comments to document the requirements this places on list_commands() and list_common_cmds_help().

---
 builtin/help.c |    5 +++++
 help.c         |    4 ++++
 2 files changed, 9 insertions(+), 0 deletions(-)
builtin/help.c +5 -0
index 3182a2b..1626251 100644
@@ -271,6 +271,11 @@ static int git_help_config(const char *var, const char *value, void *cb)
 
 static struct cmdnames main_cmds, other_cmds;
 
+/*
+ * Used for plain 'git' and 'git help'.
+ * Therefore this should not use git_config(), nor any other function
+ * that requires searching for a repository.
+ */
 void list_common_cmds_help(void)
 {
 	int i, longest = 0;
help.c +4 -0
index 7f4928e..d4c3165 100644
@@ -221,6 +221,10 @@ void load_command_list(const char *prefix,
 	exclude_cmds(other_cmds, main_cmds);
 }
 
+/*
+ * Used for 'git help -a'.  Therefore this should not use git_config(),
+ * nor any other function that requires searching for a repository.
+ */
 void list_commands(const char *title, struct cmdnames *main_cmds,
 		   struct cmdnames *other_cmds)
 {
Signature · 1 line
1.7.0.rc1.541.g2da82.dirty

From 092b20337ac1f1824a6656ba5249b409626ca52e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= <[email protected]>
Date: Sun, 21 Mar 2010 17:30:34 +0700
Subject: [PATCH] worktree setup: restore original state when things go wrong
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In current state of setup_git_directory_gently(), when a repository is not found, many things will not be the same as when setup procedure is started (while they should be). For one thing, current working directory will not be the same in certain cases.

This patch reorders actions in clear steps and rolls back if one step is wrong. (Actually the last step, setting git_dir, can't be rolled back by this patch).

The steps and their state change are:

1. Looking in working directory for repository candidates (or $GIT_DIR if it is set)

This step may move $(cwd) to somewhere.

2. Set internal variables to record repository features, based only on repository location and environment variables.

This step sets variables:
- inside_git_dir
- inside_work_tree

3. Inspect $GIT_DIR/config to see if it's a valid repository.

This step may change variables:
- repository_format_version
- shared_repository
- is_bare_repository_cfg
- git_work_tree_cfg

4. Save the repository location for later use.

This step calls setup_git_dir() to set many variables in environment.c

5. Calculate prefix (relative path to the original current working directory)

Setup procedure is completed at step 5. Stopping at any other steps is considered a setup failure.

In case of setup failure, if it's not fatal and nongit_ok is not NULL, prefix must be calculated before returning to caller. In other words:

  if (!fatal && gently)
    goto step_5;

Things that go wrong before step 4 will be cleaned up by unset_git_directory(). Step 4 is irreversible, for now.

---
 cache.h |    1 +
 setup.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 52 insertions(+), 4 deletions(-)
cache.h +1 -0
index 57cd79e..4debeaa 100644
@@ -409,6 +409,7 @@ extern const char **get_pathspec(const char *prefix, const char **pathspec);
 extern void setup_work_tree(void);
 extern const char *setup_git_directory_gently(int *);
 extern const char *setup_git_directory(void);
+extern void unset_git_directory(const char *prefix);
 extern const char *prefix_path(const char *prefix, int len, const char *path);
 extern const char *prefix_filename(const char *prefix, int len, const char *path);
 extern int check_filename(const char *prefix, const char *name);
setup.c +51 -4

84 lines not on this page · raw message

Signature · 1 line
1.7.0.rc1.541.g2da82.dirty

From 1c1e4af05262b57f5779e7f825e25945c8c21754 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= <[email protected]>
Date: Sun, 21 Mar 2010 17:30:46 +0700
Subject: [PATCH] Guard unallowed access to repository when it's not set up
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Many code path will skip repo access if startup_info->have_repository is false. This may be a fault if startup_info->have_repository has not been properly initialized.

So the rule is one of the following commands must be run before any repo access. And none of them can be called twice.

- setup_git_directory*
- enter_repo
- init_db

---
 builtin/init-db.c |    1 +
 cache.h           |    1 +
 config.c          |    2 ++
 environment.c     |   13 +++++++++++--
 git.c             |   16 +++++++++++-----
 setup.c           |   13 +++++++++++++
 6 files changed, 39 insertions(+), 7 deletions(-)
builtin/init-db.c +1 -0
index 5b2113b..8242fb9 100644
@@ -288,6 +288,7 @@ int init_db(const char *git_dir, const char *template_dir, unsigned int flags)
 
 	set_git_dir(make_absolute_path(git_dir));
 	startup_info->have_repository = 1;
+	startup_info->have_run_setup_gitdir = 1;
 
 	safe_create_dir(get_git_dir(), 0);
 
cache.h +1 -0
index 1b55ad7..c118935 100644
@@ -1046,6 +1046,7 @@ int split_cmdline(char *cmdline, const char ***argv);
 /* git.c */
 struct startup_info {
 	const char *prefix;
+	int have_run_setup_gitdir;
 	int have_repository;
 	int help;
 };
config.c +2 -0
index 07d854a..9981b09 100644
@@ -737,6 +737,8 @@ int git_config(config_fn_t fn, void *data)
 	char *repo_config = NULL;
 	int ret;
 
+	if (startup_info && !startup_info->have_run_setup_gitdir)
+		die("internal error: access to .git/config without repo setup");
 	if (!startup_info || startup_info->have_repository)
 		repo_config = git_pathdup("config");
 	ret = git_config_early(fn, data, repo_config);
environment.c +11 -2
index ead00a3..ca34a7b 100644
@@ -81,9 +81,18 @@ void unset_git_env(void)
 
 static void setup_git_env(void)
 {
+	if (startup_info && startup_info->have_run_setup_gitdir)
+		die("internal error: setup_git_env can't be called twice");
 	git_dir = getenv(GIT_DIR_ENVIRONMENT);
-	if (!git_dir)
-		git_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
+	if (!git_dir) {
+		/*
+		 * Repo detection should be done by setup_git_directory*
+		 * or enter_repo, not by this function
+		 */
+		 if (startup_info)
+			 die("internal error: $GIT_DIR is empty");
+		 git_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
+	}
 	if (!git_dir)
 		git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
 	git_object_dir = getenv(DB_ENVIRONMENT);
git.c +11 -5
index deba49a..21272d8 100644
@@ -242,11 +242,14 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 			int nongit_ok;
 			setup_git_directory_gently(&nongit_ok);
 		}
-		else if (startup_info->have_repository) {
-			if (p->option & (RUN_SETUP_GENTLY | RUN_SETUP))
-				; /* done already */
-			else
-				unset_git_directory(startup_info->prefix);
+		else if (startup_info->have_run_setup_gitdir) {
+			if (startup_info->have_repository) {
+				if (p->option & (RUN_SETUP_GENTLY | RUN_SETUP))
+					; /* done already */
+				else
+					unset_git_directory(startup_info->prefix);
+			}
+			startup_info->have_run_setup_gitdir = 0;
 		}
 
 		if (use_pager == -1 && p->option & RUN_SETUP)
@@ -257,6 +260,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 			use_pager = 1;
 		}
 	}
+	else
+		/* Stop git_config() from complaining that no repository found. */
+		startup_info->have_run_setup_gitdir = 1;
 	commit_pager_choice();
 
 	if (!startup_info->help && p->option & NEED_WORK_TREE)
setup.c +13 -0
index 7938481..3bb3a92 100644
@@ -236,7 +236,17 @@ void setup_work_tree(void)
 		git_dir = make_absolute_path(git_dir);
 	if (!work_tree || chdir(work_tree))
 		die("This operation must be run in a work tree");
+
+	/*
+	 * have_run_setup_gitdir is unset in order to avoid die()ing
+	 * inside set_git_env(). We don't actually initialize
+	 * repo twice, we're just relative-izing gitdir
+	 */
+	if (startup_info)
+		startup_info->have_run_setup_gitdir = 0;
 	set_git_dir(make_relative_path(git_dir, work_tree));
+	if (startup_info)
+		startup_info->have_run_setup_gitdir = 1;
 	initialized = 1;
 }
 
@@ -339,6 +349,7 @@ void unset_git_directory(const char *prefix)
 			unset_git_env();
 		startup_info->prefix = NULL;
 		startup_info->have_repository = 0;
+		startup_info->have_run_setup_gitdir = 0;
 	}
 
 	/* Initialized in setup_git_directory_gently_1() */
@@ -513,6 +524,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	prefix = setup_git_directory_gently_1(nongit_ok);
 	if (startup_info) {
 		startup_info->prefix = prefix;
+		startup_info->have_run_setup_gitdir = 1;
 		startup_info->have_repository = !nongit_ok || !*nongit_ok;
 	}
 	return prefix;
@@ -607,6 +619,7 @@ char *enter_repo(char *path, int strict)
 		set_git_dir(".");
 		if (startup_info) {
 			startup_info->prefix = NULL;
+			startup_info->have_run_setup_gitdir = 1;
 			startup_info->have_repository = 1;
 		}
 		return path;
Signature · 1 line
1.7.0.rc1.541.g2da82.dirty

From 7c50eebbefc1a1afe665a0315b1416b35c2021e0 Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <[email protected]>
Date: Sun, 4 Apr 2010 18:16:53 +0200
Subject: [PATCH] t0001: Add test cases for "git init" with aliases
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 t/t0001-init.sh |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)
t/t0001-init.sh +52 -0

58 lines not on this page · raw message

Signature · 1 line
1.7.0.rc1.541.g2da82.dirty
#4 lore raw

Re: nd/setup

Quoted 3 lines · Nguyen Thai Ngoc Duy

I wanted to update nd/setup topic, but found nd/root-git was merged in between its two parts, which resulted in non-trivial conflicts in the end.

I am not quite sure what you want me to do. Replacing these named commits in place (meaning, the merge with nd/root-git to adjust the later parts that depend on that fix is reproduced while rebuilding the topic) has some silly conflicts, and rebuilding the whole series without the merge but with the named commits replaced has different conflicts.

As the fix of nd/root-git is already in 'master', it might make more sense to apply the whole series rebased to the newer codebase instead of keeping the same fork point as the older series. That also removes the worries for you about having to send conflict resolutions, no?

#5 lore raw

Re: nd/setup

In reply to Jonathan Nieder
Quoted 6 lines · Jonathan Nieder
Quoted 2 lines · Nguyen Thai Ngoc Duy

I haven't forgotten the "git init" with alias bug Jonathan found. Just a little busy with other stuff.

You already fixed it, I think. ;-)

Hmm.. so I do forget something. I still miss some of your good tests though.

Quoted 21 lines

-- %< --
Subject: Revert "help: use RUN_SETUP_GENTLY"

Commit 717b8850580ecb9009505f71ea43ecda51ac1f0e taught ‘git help’ to unconditionally looks for a git directory, with the justification:

   So the sooner we set up gitdir, the less trouble we may have to deal with.

In the case of ‘git help -a’, that is not quite true.  In automount setups like that which prompted v1.6.0-rc0~121^2~1 (Add support for GIT_CEILING_DIRECTORIES, 2008-05-19), if GIT_CEILING_DIRECTORIES is unset, then probing for the Git directory can take a long time.  Thus unnecessarily searching for a git directory can slow down ‘git help -a’ (and thus bash completion).

‘git help’ does not use RUN_SETUP or USE_PAGER, and neither option parsing nor producing output for plain ‘git help’ or ‘git help -a’ requires access to the git configuration.  Therefore it is safe to not search for the git directory early in this case.

Quoted 4 lines

Also add some comments to document the requirements this places on list_commands() and list_common_cmds_help().

Didn't notice it. Looks good. I will replace the "help: use RUN_SETUP_GENTLY" commit with this patch next time, if you don't mind.

Signature · 1 line
Duy
#6 lore raw
In reply to Junio C Hamano

Heya,

Quoted 11 lines · Junio C Hamano

* sr/remote-helper-export (2010-03-29) 7 commits
 - remote-helpers: add tests for testgit helper
 - remote-helpers: add testgit helper
 - remote-helpers: add support for an export command
 - remote-helpers: allow requesing the path to the .git directory
 - fast-import: always create marks_file directories
 - clone: also configure url for bare clones
 - clone: pass the remote name to remote_get

May merge to 'next', but I would prefer waiting til 1.7.2 to have this with a confidence than fast-tracking it.

Agreed, if 1.7.2 will be a short cycle I don't mind waiting a few more weeks :).

Signature · 3 lines
Cheers,

Sverre Rabbelier