Skip to content
Commits on Jan 22, 2016
  1. @pclouds @gitster

    worktree: stop supporting moving worktrees manually

    pclouds committed with gitster
    The current update_linked_gitdir() has a bug that can create "gitdir"
    file in non-multi-worktree setup. Worse, sometimes it can write relative
    path to "gitdir" file, which will not work (e.g. "git worktree list"
    will display the worktree's location incorrectly)
    
    Instead of fixing this, we step back a bit. The original design was
    probably not well thought out. For now, if the user manually moves a
    worktree, they have to fix up "gitdir" file manually or the worktree
    will get pruned.
    
    Helped-by: Eric Sunshine <sunshine@sunshineco.com>
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 25, 2015
  1. @pclouds @gitster

    setup: update the right file in multiple checkouts

    pclouds committed with gitster
    This code is introduced in 23af91d (prune: strategies for linked
    checkouts - 2014-11-30), and it's supposed to implement this rule from
    that commit's message:
    
     - linked checkouts are supposed to keep its location in $R/gitdir up
       to date. The use case is auto fixup after a manual checkout move.
    
    Note the name, "$R/gitdir", not "$R/gitfile". Correct the path to be
    updated accordingly.
    
    While at there, make sure I/O errors are not silently dropped.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on May 3, 2015
  1. @pclouds @gitster

    pathspec: avoid the need of "--" when wildcard is used

    pclouds committed with gitster
    When "--" is lacking from the command line and a command can take
    both revs and paths, the idea is if an argument can be seen as both
    an extended SHA-1 and a path, then "--" is required or git refuses
    to continue. It's currently implemented as:
    
     (1) if an argument is rev, then it must not exist in worktree
    
     (2) else, it must exist in worktree
    
     (3) else, "--" is required.
    
    These rules work for literal paths, but when non-literal pathspec is
    involved, it almost always requires the user to add "--" because it
    fails (2) and (1) is really rarely met (take "*.c" for example, (1)
    is met if there is a ref named "*.c").
    
    This patch modifies the rules a bit by considering any valid (*)
    wildcard pathspec "exist in worktree". The rules become:
    
     (1) if an arg is a rev, then it must either exist in worktree or
         not be a valid wildcard pathspec.
    
     (2) else, it either exists in worktree or is a wildcard pathspec
    
     (3) else, "--" is required.
    
    With the new rules, "--" is not needed most of the time when
    wildcard pathspec is involved.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 1, 2014
  1. @pclouds @gitster

    prune: strategies for linked checkouts

    pclouds committed with gitster
    (alias R=$GIT_COMMON_DIR/worktrees/<id>)
    
     - linked checkouts are supposed to keep its location in $R/gitdir up
       to date. The use case is auto fixup after a manual checkout move.
    
     - linked checkouts are supposed to update mtime of $R/gitdir. If
       $R/gitdir's mtime is older than a limit, and it points to nowhere,
       worktrees/<id> is to be pruned.
    
     - If $R/locked exists, worktrees/<id> is not supposed to be pruned. If
       $R/locked exists and $R/gitdir's mtime is older than a really long
       limit, warn about old unused repo.
    
     - "git checkout --to" is supposed to make a hard link named $R/link
       pointing to the .git file on supported file systems to help detect
       the user manually deleting the checkout. If $R/link exists and its
       link count is greated than 1, the repo is kept.
    
    Helped-by: Marc Branchaud <marcnarc@xiplink.com>
    Helped-by: Eric Sunshine <sunshine@sunshineco.com>
    Helped-by: Johannes Sixt <j6t@kdbg.org>
    Signed-off-by: Marc Branchaud <marcnarc@xiplink.com>
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @pclouds @gitster

    setup.c: support multi-checkout repo setup

    pclouds committed with gitster
    The repo setup procedure is updated to detect $GIT_DIR/commondir and
    set $GIT_COMMON_DIR properly.
    
    The core.worktree is ignored when $GIT_COMMON_DIR is set. This is
    because the config file is shared in multi-checkout setup, but
    checkout directories _are_ different. Making core.worktree effective
    in all checkouts mean it's back to a single checkout.
    
    Helped-by: Johannes Sixt <j6t@kdbg.org>
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. @pclouds @gitster

    setup.c: detect $GIT_COMMON_DIR check_repository_format_gently()

    pclouds committed with gitster
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. @pclouds @gitster

    setup.c: convert check_repository_format_gently to use strbuf

    pclouds committed with gitster
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. @pclouds @gitster

    setup.c: detect $GIT_COMMON_DIR in is_git_directory()

    pclouds committed with gitster
    If the file "$GIT_DIR/commondir" exists, it contains the value of
    $GIT_COMMON_DIR.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6. @pclouds @gitster

    setup.c: convert is_git_directory() to use strbuf

    pclouds committed with gitster
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 10, 2014
  1. @pclouds @gitster

    daemon: move daemonize() to libgit.a

    pclouds committed with gitster
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 15, 2013
  1. @pclouds @gitster

    parse_pathspec: make sure the prefix part is wildcard-free

    pclouds committed with gitster
    Prepending prefix to pathspec is a trick to workaround the fact that
    commands can be executed in a subdirectory, but all git commands run
    at worktree's root. The prefix part should always be treated as
    literal string. Make it so.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @pclouds @gitster

    move struct pathspec and related functions to pathspec.[ch]

    pclouds committed with gitster
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jan 22, 2013
  1. @pclouds @gitster

    Update :/abc ambiguity check

    pclouds committed with gitster
    :/abc may mean two things:
    
    - as a revision, it means the revision that has "abc" in commit
      message.
    
    - as a pathpec, it means "abc" from root.
    
    Currently we see ":/abc" as a rev (most of the time), but never see it
    as a pathspec even if "abc" exists and "git log :/abc" will gladly
    take ":/abc" as rev even it's ambiguous. This patch makes it:
    
    - ambiguous when "abc" exists on worktree
    - a rev if abc does not exist on worktree
    - a path if abc is not found in any commits (although better use
      "--" to avoid ambiguation because searching through commit DAG is
      expensive)
    
    A plus from this patch is, because ":/" never matches anything as a
    rev, it is never considered a valid rev and because root directory
    always exists, ":/" is always unambiguously seen as a pathspec.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 29, 2011
  1. @pclouds @gitster

    setup: return correct prefix if worktree is '/'

    pclouds committed with gitster
    The same old problem reappears after setup code is reworked.  We tend
    to assume there is at least one path component in a path and forget
    that path can be simply '/'.
    
    Reported-by: Matthijs Kooijman <matthijs@stdin.nl>
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 27, 2010
  1. @pclouds @gitster

    setup_work_tree: adjust relative $GIT_WORK_TREE after moving cwd

    pclouds committed with gitster
    When setup_work_tree() is called, it moves cwd to $GIT_WORK_TREE and
    makes internal copy of $GIT_WORK_TREE absolute. The environt variable,
    if set by user, remains unchanged. If the variable is relative, it is
    no longer correct because its base dir has changed.
    
    Instead of making $GIT_WORK_TREE absolute too, we just say "." and let
    subsequent git processes handle it.
    
    Reported-by: Michel Briand <michelbriand@free.fr>
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 22, 2010
  1. @pclouds @gitster

    setup: rework setup_explicit_git_dir()

    pclouds committed with gitster
    This function is the most complex one among the three setup_*
    functions because all GIT_DIR, GIT_WORK_TREE, core.worktree and
    core.bare are involved.
    
    Because core.worktree is only effective inside
    setup_explicit_git_dir() and the extra code in setup_git_directory()
    is to handle that. The extra code can now be retired.
    
    Also note that setup_explicit assignment is removed, worktree setting
    is no longer decided by get_git_work_tree(). get_git_work_tree() will
    be simplified in the next commit.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @pclouds @gitster

    setup: clean up setup_discovered_git_dir()

    pclouds committed with gitster
    If core.bare is true, discard the discovered worktree, move back to
    original cwd.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. @pclouds @gitster

    setup: clean up setup_bare_git_dir()

    pclouds committed with gitster
    work_tree_env argument is removed because this function does not need
    it. GIT_WORK_TREE is only effective inside setup_explicit_git_dir.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. @pclouds @gitster

    setup: limit get_git_work_tree()'s to explicit setup case only

    pclouds committed with gitster
    get_git_work_tree() takes input as core.worktree, core.bare,
    GIT_WORK_TREE and decides correct worktree setting.
    
    Unfortunately it does not do its job well. core.worktree and
    GIT_WORK_TREE should only be taken into account, if GIT_DIR is set
    (which is handled by setup_explicit_git_dir). For other setup cases,
    only core.bare matters.
    
    Add a temporary variable setup_explicit to adjust get_git_work_tree()
    behavior as such. This variable will be gone once setup_* rework is
    done.
    
    Also remove is_bare_repository_cfg check in set_git_work_tree() to
    ease the rework. We are going to check for core.bare and core.worktree
    early before setting worktree. For example, if core.bare is true, no
    need to set worktree.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. @pclouds @gitster

    Use git_config_early() instead of git_config() during repo setup

    pclouds committed with gitster
    When git_config() is called, either git_dir has already been set (by
    $GIT_DIR env or set_git_dir()), or it will default git_dir to ".git".
    
    git_config_early() gives setup functions more freedom because it does
    not require git_dir. Give it a config path, it will happily examine
    it.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 7, 2010
  1. @pclouds @gitster

    Make prefix_path() return char* without const

    pclouds committed with gitster
    prefix_path() allocates new buffer. There's no reason for it to keep
    the buffer for itself and waste memory.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @pclouds @gitster

    setup: save prefix (original cwd relative to toplevel) in startup_info

    pclouds committed with gitster
    Save the path from the original cwd to the cwd at the end of the
    setup procedure in the startup_info struct introduced in e37c132
    (2010-08-05).  The value cannot vary from thread to thread anyway,
    since the cwd is global.
    
    So now in your builtin command, instead of passing prefix around,
    when you want to convert a user-supplied path to a cwd-relative
    path, you can use startup_info->prefix directly.
    
    Caveat: As with the return value from setup_git_directory_gently(),
    startup_info->prefix would be NULL when the original cwd is not a
    subdir of the toplevel.
    
    Longer term, this would allow the prefix to be reused when several
    noncooperating functions require access to the same repository (for
    example, when accessing configuration before running a builtin).
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 11, 2010
  1. @pclouds @gitster

    setup: remember whether repository was found

    pclouds committed with gitster
    As v1.7.2~16^2 (git --paginate: paginate external commands
    again, 2010-07-14) explains, builtins (like git config) that
    do not use RUN_SETUP are not finding GIT_DIR set correctly when
    it is time to launch the pager from run_builtin().  If they
    were to search for a repository sooner, then the outcome of such
    early repository accesses would be more predictable and reliable.
    
    The cmd_*() functions learn whether a repository was found through the
    *nongit_ok return value from setup_git_directory_gently().  If
    run_builtin() is to take care of the repository search itself, that
    datum needs to be retrievable from somewhere else.  Use the
    startup_info struct for this.
    
    As a bonus, this information becomes available to functions such as
    git_config() which might want to avoid trying to access a repository
    when none is present.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 4, 2010
  1. @pclouds @gitster

    setup: split off a function to handle ordinary .git directories

    pclouds committed with gitster
    Finish the clean-up of setup_git_directory_gently() by splitting the
    last case of validation+setup (global variables, prefix, check_format,
    set_git_dir) into its own function.  Now setup_git_git_directory_gently
    itself takes care of discovery only and the functions that pick up
    from there are nearby in the source file so they can be easily
    compared.
    
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @pclouds @gitster

    setup: do not forget working dir from subdir of gitdir

    pclouds committed with gitster
    v1.6.1.3~4^2 (Fix gitdir detection when in subdir of gitdir,
    2009-01-16) did not go far enough: when a git directory is
    an ancestor of the original working directory, not only
    should GIT_DIR be set to point to the .git directory, but
    the original working directory should be restored before
    carrying out the relevant command.
    
    This way, the effect of running a git command from a subdir
    of .git will be the same whether or not GIT_DIR is explicitly
    set.
    
    Noticed while investigating v1.6.0.3~1 (rehabilitate 'git
    index-pack' inside the object store, 2008-10-20).
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 16, 2010
  1. @pclouds @gitster

    Support working directory located at root

    pclouds committed with gitster
    Git should work regardless where the working directory is located,
    even at root. This patch fixes two places where it assumes working
    directory always have parent directory.
    
    In setup_git_directory_gently(), when Git goes up to root and finds
    .git there, it happily sets worktree to "" instead of "/".
    
    In prefix_path(), loosen the outside repo check a little bit. Usually
    when a path XXX is inside worktree /foo, it must be either "/foo", or
    "/foo/...". When worktree is simply "/", we can safely ignore the
    check: we have a slash at the beginning already.
    
    Not related to worktree, but also set gitdir correctly if a bare repo
    is placed (insanely?) at root.
    
    Thanks João Carlos Mendes Luís for pointing out this problem.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 31, 2008
  1. @pclouds @gitster

    setup_git_directory(): fix move to worktree toplevel directory

    pclouds committed with gitster
    When setup_git_directory() returns successfully, it is supposed to move
    current working directory to worktree toplevel directory.
    
    However, the code recomputing prefix inside setup_git_directory() has
    to move cwd back to original working directory, in order to get new
    prefix.  After that, it should move cwd back to worktree toplevel
    directory as expected.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 9, 2007
  1. @pclouds @gitster

    Remove repo version check from setup_git_directory

    pclouds committed with gitster
    setup_git_directory_gently has done the check already.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Dec 5, 2007
  1. @pclouds @gitster

    Do check_repository_format() early (re-fix)

    pclouds committed with gitster
    This pushes check_repository_format() (actually _gently() version)
    to setup_git_directory_gently() in order to prevent from
    using unsupported repositories.
    
    New setup_git_directory_gently()'s behaviour is stop searching
    for a valid gitdir and return as if there is no gitdir if a
    unsupported repository is found. Warning will be thrown in these
    cases.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Nov 30, 2007
  1. @pclouds @gitster

    Do check_repository_format() early

    pclouds committed with gitster
    Repository version check is only performed when
    setup_git_directory() is called. This makes sure
    setup_git_directory_gently() does the check too.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Nov 4, 2007
  1. @pclouds @gitster

    Add missing inside_work_tree setting in setup_git_directory_gently

    pclouds committed with gitster
    When both GIT_DIR and GIT_WORK_TREE are set, and
    setup_git_directory_gently() changes the current working
    directory accordingly, it should also set inside_work_tree = 1.
    
    Without this, work_tree handling code in setup_git_directory()
    will be activated. If you stay in root work tree (no prefix),
    it does not harm. It does if you work from a subdirectory though.
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Something went wrong with that request. Please try again.