[PATCH v2 0/1] Add hostname condition to includeIf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Extend includeIf to take hostname into account. Motivating request can
be found here [1].

[1] https://github.com/gitgitgadget/git/issues/1665

Changes since v1:
* Add blank line between declarations and code in `include_by_branch`.
* Rewrite "echo"s used in tests to make them more readable. 

  config: learn the "hostname:" includeIf condition

 Documentation/config.txt  |  9 +++++++++
 config.c                  | 17 ++++++++++++++++
 t/t1305-config-include.sh | 42 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)

Range-diff against v1:
1:  10a9bca68753 ! 1:  cf175154109e config: learn the "hostname:" includeIf condition
    @@ config.c: static int include_by_branch(const char *cond, size_t cond_len)
     +	int ret;
     +	char my_host[HOST_NAME_MAX + 1];
     +	struct strbuf pattern = STRBUF_INIT;
    ++
     +	if (xgethostname(my_host, sizeof(my_host)))
     +		return 0;
     +
    @@ t/t1305-config-include.sh: test_expect_success 'include cycles are detected' '
      '
      
     +test_expect_success 'conditional include, hostname' '
    -+	echo "[includeIf \"hostname:$(hostname)a\"]path=bar12" >>.git/config &&
    -+	echo "[test]twelve=12" >.git/bar12 &&
    ++	cat >>.git/config <<-EOF &&
    ++	[includeIf "hostname:$(hostname)a"]
    ++		path = bar12
    ++	EOF
    ++	cat >>.git/bar12 <<-EOF &&
    ++	[test]
    ++		twelve=12
    ++	EOF
    ++
     +	test_must_fail git config test.twelve &&
     +
    -+	echo "[includeIf \"hostname:$(hostname)\"]path=bar12" >>.git/config &&
    ++	cat >>.git/config <<-EOF &&
    ++	[includeIf "hostname:$(hostname)"]
    ++		path = bar12
    ++	EOF
     +	echo 12 >expect &&
     +	git config test.twelve >actual &&
     +	test_cmp expect actual
     +'
     +
     +test_expect_success 'conditional include, hostname, wildcard' '
    -+	echo "[includeIf \"hostname:$(hostname)a*\"]path=bar13" >>.git/config &&
    -+	echo "[test]thirteen=13" >.git/bar13 &&
    ++	cat >>.git/config <<-EOF &&
    ++	[includeIf "hostname:$(hostname)a*"]
    ++		path = bar13
    ++	EOF
    ++	cat >>.git/bar13 <<-EOF &&
    ++	[test]
    ++		thirteen = 13
    ++	EOF
    ++
     +	test_must_fail git config test.thirteen &&
     +
    -+	echo "[includeIf \"hostname:$(hostname)*\"]path=bar13" >>.git/config &&
    ++	cat >>.git/config <<-EOF &&
    ++	[includeIf "hostname:$(hostname)*"]
    ++		path = bar13
    ++	EOF
     +	echo 13 >expect &&
     +	git config test.thirteen >actual &&
     +	test_cmp expect actual

base-commit: e09f1254c54329773904fe25d7c545a1fb4fa920
-- 
2.44.0





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux