COMP(2041|9044) 24T1 — Assignment 1: Pushy
Subset 1 原题:
Subset 1 is more difficult. You will need to spend some time understanding the semantics (meaning) of these operations, by running the reference implementation, or researching the equivalent Git operations.
Note the assessment scheme recognises this difficulty.
Subset 1 commands must be implemented in POSIX-compatible Shell.
See the Permitted Languages section for more information.
pushy-commit [-a] -m message
pushy-commit
can now have a -a
option,
which causes all files already in the index to have their contents from the current directory added to the index before the commit.
pushy-rm [--force] [--cached] filenames...
pushy-rm
removes a file from the index, or, from the current directory and the index.
If the --cached
option is specified, the file is removed only from the index, and not from the current directory.
pushy-rm
, like git rm
, should stop the user accidentally losing work, and should give an error message instead if the removal would cause the user to lose work. You will need to experiment with the reference implementation to discover these error messages. Researching git rm
's behaviour may also help.
The --force
option overrides this, and will carry out the removal even if the user will lose work.
pushy-status
pushy-status
shows the status of files in the current directory, the index, and the repository.
There are many different cases to consider for pushy-status
.
You will need to experiment with the reference implementation to find them all.
Subset 1 原题讲解:
这个题目要求你实现一套基于 Shell 的版本控制命令,与 Git 类似,但功能更为简化。这套命令包括 pushy-commit
、pushy-rm
和 pushy-status
,要求在一个 POSIX 兼容的 Shell 环境中实现。让我们逐一分析这些命令的要求和功能。
pushy-commit
这个命令用于提交当前在索引(index)中的更改。
- 这个命令有一个新的选项
-a
,当这个选项被使用时,它会先将当前目录中,所有已经在索引中的文件的最新内容添加到索引。 - 必须要有
-m