<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git-branch-list/t, branch master</title>
<subtitle>A Git add-on that maintains a list of branches that can be checked out quickly</subtitle>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/git-branch-list/'/>
<entry>
<title>git-branch-list: Allow commands to work in Git worktrees</title>
<updated>2020-03-12T23:33:27+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2020-03-12T23:33:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/git-branch-list/commit/?id=8061c43bb08b253f81283bce1bd83d2be6a77263'/>
<id>8061c43bb08b253f81283bce1bd83d2be6a77263</id>
<content type='text'>
Previously, `git-branch-list` didn't work inside worktree directories.
It expected the current directory to be a descendant of the main Git
repository directory, which isn't the case for worktrees.

Given a Git repository `test-repo`:

    $ git rev-parse --show-toplevel
    /tmp/test-repo
    $ git rev-parse --git-common-dir
    .git
    $ mkdir subdir &amp;&amp; cd subdir
    $ git rev-parse --git-common-dir
    ../.git
    $ cd -

    $ git worktree add ../test-repo-worktree
    $ cd ../test-repo-worktree
    $ git rev-parse --show-toplevel
    /tmp/test-repo-worktree
    $ git rev-parse --git-common-dir
    /tmp/test-repo/.git

The `git rev-parse --show-toplevel` command outputs the top-level path
of the worktree, not the main repository directory. Using `git rev-parse
--git-common-dir`, we can get the correct path whether we're in a
subdirectory or a worktree.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, `git-branch-list` didn't work inside worktree directories.
It expected the current directory to be a descendant of the main Git
repository directory, which isn't the case for worktrees.

Given a Git repository `test-repo`:

    $ git rev-parse --show-toplevel
    /tmp/test-repo
    $ git rev-parse --git-common-dir
    .git
    $ mkdir subdir &amp;&amp; cd subdir
    $ git rev-parse --git-common-dir
    ../.git
    $ cd -

    $ git worktree add ../test-repo-worktree
    $ cd ../test-repo-worktree
    $ git rev-parse --show-toplevel
    /tmp/test-repo-worktree
    $ git rev-parse --git-common-dir
    /tmp/test-repo/.git

The `git rev-parse --show-toplevel` command outputs the top-level path
of the worktree, not the main repository directory. Using `git rev-parse
--git-common-dir`, we can get the correct path whether we're in a
subdirectory or a worktree.
</pre>
</div>
</content>
</entry>
<entry>
<title>git-branch-list: Fix checkout and drop commands for &gt;10 saved branches</title>
<updated>2019-12-09T20:24:03+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2019-12-09T20:24:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/git-branch-list/commit/?id=f0993eb7d45a414030b15091fe47a08110f71e7f'/>
<id>f0993eb7d45a414030b15091fe47a08110f71e7f</id>
<content type='text'>
Previously there was a bug when you had 11 or more saved branches. Saved
branches 1 and 11 would both get matched by the regex in `branch_by_id`,
causing the two branches to be concatenated.

This resulted in a checkout error, preventing checkout. When dropping a
branch, both in the pair would be dropped, even if only branch #1 was
specified.

Surround the branch IDs with whitespace to prevent incorrect matches.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously there was a bug when you had 11 or more saved branches. Saved
branches 1 and 11 would both get matched by the regex in `branch_by_id`,
causing the two branches to be concatenated.

This resulted in a checkout error, preventing checkout. When dropping a
branch, both in the pair would be dropped, even if only branch #1 was
specified.

Surround the branch IDs with whitespace to prevent incorrect matches.
</pre>
</div>
</content>
</entry>
<entry>
<title>git-branch-list: Make the branch list work in subdirectories</title>
<updated>2019-05-25T09:34:04+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2019-05-25T09:34:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/git-branch-list/commit/?id=18ec1361d4eea49066aa12ccb2b173f196962f66'/>
<id>18ec1361d4eea49066aa12ccb2b173f196962f66</id>
<content type='text'>
When the current directory was not the Git root, the command wouldn't
work. It expected to find the branch list database in the `.git`
directory in the current directory.

Make the program work even if the current directory is a subdirectory of
the Git repository.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When the current directory was not the Git root, the command wouldn't
work. It expected to find the branch list database in the `.git`
directory in the current directory.

Make the program work even if the current directory is a subdirectory of
the Git repository.
</pre>
</div>
</content>
</entry>
<entry>
<title>git-branch-list(drop): Fix deletion for branches with slashes</title>
<updated>2018-04-19T21:44:13+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-04-19T21:44:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/git-branch-list/commit/?id=3f6e62684b1fb1167435c6fa4f6c6f02aaff3937'/>
<id>3f6e62684b1fb1167435c6fa4f6c6f02aaff3937</id>
<content type='text'>
Previously, if a branch name had slashes in it, the `drop` command would
fail. This is because it used `sed` with `/` separators, and the
unescaped slashes in the branch name would mess up sed's pattern.

Change this to use grep instead of sed so we don't have to worry about
escaping and special characters in branch names.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, if a branch name had slashes in it, the `drop` command would
fail. This is because it used `sed` with `/` separators, and the
unescaped slashes in the branch name would mess up sed's pattern.

Change this to use grep instead of sed so we don't have to worry about
escaping and special characters in branch names.
</pre>
</div>
</content>
</entry>
<entry>
<title>git-branch-list(drop): Support multiple branches with similar names</title>
<updated>2018-04-19T21:08:09+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-04-19T21:08:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/git-branch-list/commit/?id=7bb9292f60c8889b2a3529748679025d73e9d645'/>
<id>7bb9292f60c8889b2a3529748679025d73e9d645</id>
<content type='text'>
Previously if you had multiple branches with similar names, they could
all be deleted when deleting a single one.

For example:

    $ git branch-list
      1 a-branch-with-suffix
      2 a-branch
    $ git branch-list drop 2
    $ git branch-list
    $

Change the regex used to match branches to drop to match the whole line,
so we don't accidentally delete a branch when it has a positive partial
match.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously if you had multiple branches with similar names, they could
all be deleted when deleting a single one.

For example:

    $ git branch-list
      1 a-branch-with-suffix
      2 a-branch
    $ git branch-list drop 2
    $ git branch-list
    $

Change the regex used to match branches to drop to match the whole line,
so we don't accidentally delete a branch when it has a positive partial
match.
</pre>
</div>
</content>
</entry>
<entry>
<title>git-branch-list(drop): Add support for multiple branch arguments</title>
<updated>2018-03-21T16:38:54+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-03-21T16:38:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/git-branch-list/commit/?id=64fe9fc7fa4e073d6bb97cdee0d2914abb943391'/>
<id>64fe9fc7fa4e073d6bb97cdee0d2914abb943391</id>
<content type='text'>
Allow users to drop multiple branches in a single command. Instead of:

    $ git branch-list 1
    $ git branch-list 3
    $ git branch-list 4

you can now do:

    $ git branch-list 1 3 4

This makes it easier to drop a bunch of branches that you no longer need
saved.

drop_branch():
* No longer uses `branch_or_current_branch()`. Kept that function around
  because I didn't feel like touching the `save_branch()` code, and
  extracted the Git command to get the current branch to a new
  `current_branch()` function.
* Used one loop to get branch names from IDs if necessary and feed these
  into a Bash array. A second loop just after deletes all branches in
  the branch array using the `sed` method from before. Didn't feel like
  changing the `sed` command so did it this way. That said, we're
  probably going to have to come back to it sooner or later because it's
  not going to be able to handle branch names containing slashes.

main `case`:
Change `drop_branch` call to pass it all command line arguments, except
the 0th argument, which is the "drop" command (this is why we `shift`
before calling the function).

101-drop-accepts-multiple-branch-arguments.t:
Update test expectation which had an extra newline at the start of the
string which isn't there in the real `git branch-list` output.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Allow users to drop multiple branches in a single command. Instead of:

    $ git branch-list 1
    $ git branch-list 3
    $ git branch-list 4

you can now do:

    $ git branch-list 1 3 4

This makes it easier to drop a bunch of branches that you no longer need
saved.

drop_branch():
* No longer uses `branch_or_current_branch()`. Kept that function around
  because I didn't feel like touching the `save_branch()` code, and
  extracted the Git command to get the current branch to a new
  `current_branch()` function.
* Used one loop to get branch names from IDs if necessary and feed these
  into a Bash array. A second loop just after deletes all branches in
  the branch array using the `sed` method from before. Didn't feel like
  changing the `sed` command so did it this way. That said, we're
  probably going to have to come back to it sooner or later because it's
  not going to be able to handle branch names containing slashes.

main `case`:
Change `drop_branch` call to pass it all command line arguments, except
the 0th argument, which is the "drop" command (this is why we `shift`
before calling the function).

101-drop-accepts-multiple-branch-arguments.t:
Update test expectation which had an extra newline at the start of the
string which isn't there in the real `git branch-list` output.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add `drop` command tests</title>
<updated>2018-03-21T16:17:26+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-03-21T16:17:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/git-branch-list/commit/?id=565c054f57248409eddc7ebe20629b85093f7c55'/>
<id>565c054f57248409eddc7ebe20629b85093f7c55</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>t/: Move `$BIN` variable to module</title>
<updated>2018-03-18T17:25:38+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-03-18T17:25:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/git-branch-list/commit/?id=975b9d397076e26ba205a71cac4a5db190d873f9'/>
<id>975b9d397076e26ba205a71cac4a5db190d873f9</id>
<content type='text'>
In order to be able to easily reuse the `$BIN` variable we created in
the test for the `clear` sub-command, move it to a Perl module that can
be included in other tests.

Add the `t/` directory to the include path when running `prove` to
ensure that `bin.pm` can be found and included.

Thanks to these resources for explaining Perl modules:
https://perlmaven.com/how-to-create-a-perl-module-for-code-reuse
https://stackoverflow.com/questions/23899121/perl-declare-and-export-variables-from-a-module/23900384#23900384
https://stackoverflow.com/questions/17931981/what-is-isa-in-perl/17932340#17932340
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In order to be able to easily reuse the `$BIN` variable we created in
the test for the `clear` sub-command, move it to a Perl module that can
be included in other tests.

Add the `t/` directory to the include path when running `prove` to
ensure that `bin.pm` can be found and included.

Thanks to these resources for explaining Perl modules:
https://perlmaven.com/how-to-create-a-perl-module-for-code-reuse
https://stackoverflow.com/questions/23899121/perl-declare-and-export-variables-from-a-module/23900384#23900384
https://stackoverflow.com/questions/17931981/what-is-isa-in-perl/17932340#17932340
</pre>
</div>
</content>
</entry>
<entry>
<title>git-branch-list: Add `clear` command</title>
<updated>2018-03-18T15:22:07+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-03-18T15:22:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/git-branch-list/commit/?id=4132e288ba6af49cf726d71785ec1f2ff9f39270'/>
<id>4132e288ba6af49cf726d71785ec1f2ff9f39270</id>
<content type='text'>
A new sub-command that clears the entire branch list. This makes it easy
to remove everything when all the branches in the list are stale (e.g.
everything's been merged already).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A new sub-command that clears the entire branch list. This makes it easy
to remove everything when all the branches in the list are stale (e.g.
everything's been merged already).
</pre>
</div>
</content>
</entry>
<entry>
<title>Add TAP test structure</title>
<updated>2018-03-18T15:05:30+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-03-18T15:05:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/git-branch-list/commit/?id=a47bf8ba13440c9691bf002a5bf687175d9c0937'/>
<id>a47bf8ba13440c9691bf002a5bf687175d9c0937</id>
<content type='text'>
Copied and modified from:

https://github.com/teddywing/git-hook-pre-commit-python-javascript-syntax-linter/blob/efa1909/t/001-setup.t
https://github.com/teddywing/git-hook-pre-commit-python-javascript-syntax-linter/blob/f6bb0d3/t/999-teardown.t
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Copied and modified from:

https://github.com/teddywing/git-hook-pre-commit-python-javascript-syntax-linter/blob/efa1909/t/001-setup.t
https://github.com/teddywing/git-hook-pre-commit-python-javascript-syntax-linter/blob/f6bb0d3/t/999-teardown.t
</pre>
</div>
</content>
</entry>
</feed>
